-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GrowthBook and segment dev env (#12952)
* Add growthbook * Fix data-track to match button when logged in * Add segment key for dev environment * Added cypress wait to make sure we don't scroll before the page loads * Update site.cy.js
- Loading branch information
Showing
4 changed files
with
143 additions
and
127 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,139 +233,154 @@ | |
|
||
<script async defer src="https://buttons.github.io/buttons.js"></script> | ||
|
||
{{- if eq hugo.Environment "production" }} | ||
<!-- Clearbit snippet --> | ||
<script src="https://tag.clearbitscripts.com/v1/pk_54e7d7c428c6d5e79098374d93a7b333/tags.js" referrerpolicy="strict-origin-when-cross-origin"></script> | ||
<script> | ||
var segmentWriteKey; | ||
{{- if eq hugo.Environment "production" }} | ||
segmentWriteKey = "UK90Ofwacetj5VCPJ7cUgkbNcKLSHO3u"; | ||
{{- else }} | ||
segmentWriteKey = "bATvhu6XKpwi7Cs258MGsELkDpVOzvdY"; | ||
{{- end }} | ||
</script> | ||
|
||
<!--Segment tracking--> | ||
<script> | ||
// Do not load Segment for these user agents. | ||
userAgentBlacklist = [ | ||
'Mozilla/5.0 (compatible; SiteAuditBot/0.97; +http://www.semrush.com/bot.html)', | ||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36' | ||
] | ||
|
||
!(function () { | ||
var i = "analytics", | ||
analytics = (window[i] = window[i] || []); | ||
if (!analytics.initialize) | ||
if (analytics.invoked) { | ||
window.console && console.error && console.error("Segment snippet included twice."); | ||
} else if (userAgentBlacklist.includes(navigator.userAgent)) { | ||
console.log("Segment snippet not loaded for user agent: " + navigator.userAgent); | ||
} else { | ||
analytics.invoked = !0; | ||
analytics.methods = [ | ||
"trackSubmit", | ||
"trackClick", | ||
"trackLink", | ||
"trackForm", | ||
"pageview", | ||
"identify", | ||
"reset", | ||
"group", | ||
"track", | ||
"ready", | ||
"alias", | ||
"debug", | ||
"page", | ||
"screen", | ||
"once", | ||
"off", | ||
"on", | ||
"addSourceMiddleware", | ||
"addIntegrationMiddleware", | ||
"setAnonymousId", | ||
"addDestinationMiddleware", | ||
"register", | ||
]; | ||
analytics.factory = function (e) { | ||
return function () { | ||
if (window[i].initialized) return window[i][e].apply(window[i], arguments); | ||
var n = Array.prototype.slice.call(arguments); | ||
if (["track", "screen", "alias", "group", "page", "identify"].indexOf(e) > -1) { | ||
var c = document.querySelector("link[rel='canonical']"); | ||
n.push({ __t: "bpc", c: (c && c.getAttribute("href")) || void 0, p: location.pathname, u: location.href, s: location.search, t: document.title, r: document.referrer }); | ||
} | ||
n.unshift(e); | ||
analytics.push(n); | ||
return analytics; | ||
}; | ||
}; | ||
for (var n = 0; n < analytics.methods.length; n++) { | ||
var key = analytics.methods[n]; | ||
analytics[key] = analytics.factory(key); | ||
} | ||
analytics.load = function (key, n) { | ||
var t = document.createElement("script"); | ||
t.type = "text/javascript"; | ||
t.async = !0; | ||
t.setAttribute("data-global-segment-analytics-key", i); | ||
t.src = "https://cdn.segment.com/analytics.js/v1/" + key + "/analytics.min.js"; | ||
var r = document.getElementsByTagName("script")[0]; | ||
r.parentNode.insertBefore(t, r); | ||
analytics._loadOptions = n; | ||
<!--Segment tracking--> | ||
<script> | ||
// Do not load Segment for these user agents. | ||
userAgentBlacklist = [ | ||
'Mozilla/5.0 (compatible; SiteAuditBot/0.97; +http://www.semrush.com/bot.html)', | ||
'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36' | ||
] | ||
|
||
!(function () { | ||
var i = "analytics", | ||
analytics = (window[i] = window[i] || []); | ||
if (!analytics.initialize) | ||
if (analytics.invoked) { | ||
window.console && console.error && console.error("Segment snippet included twice."); | ||
} else if (userAgentBlacklist.includes(navigator.userAgent)) { | ||
console.log("Segment snippet not loaded for user agent: " + navigator.userAgent); | ||
} else { | ||
analytics.invoked = !0; | ||
analytics.methods = [ | ||
"trackSubmit", | ||
"trackClick", | ||
"trackLink", | ||
"trackForm", | ||
"pageview", | ||
"identify", | ||
"reset", | ||
"group", | ||
"track", | ||
"ready", | ||
"alias", | ||
"debug", | ||
"page", | ||
"screen", | ||
"once", | ||
"off", | ||
"on", | ||
"addSourceMiddleware", | ||
"addIntegrationMiddleware", | ||
"setAnonymousId", | ||
"addDestinationMiddleware", | ||
"register", | ||
]; | ||
analytics.factory = function (e) { | ||
return function () { | ||
if (window[i].initialized) return window[i][e].apply(window[i], arguments); | ||
var n = Array.prototype.slice.call(arguments); | ||
if (["track", "screen", "alias", "group", "page", "identify"].indexOf(e) > -1) { | ||
var c = document.querySelector("link[rel='canonical']"); | ||
n.push({ __t: "bpc", c: (c && c.getAttribute("href")) || void 0, p: location.pathname, u: location.href, s: location.search, t: document.title, r: document.referrer }); | ||
} | ||
n.unshift(e); | ||
analytics.push(n); | ||
return analytics; | ||
}; | ||
analytics._writeKey = "UK90Ofwacetj5VCPJ7cUgkbNcKLSHO3u"; | ||
analytics.SNIPPET_VERSION = "5.2.0"; | ||
analytics.load("UK90Ofwacetj5VCPJ7cUgkbNcKLSHO3u"); | ||
analytics.page(); | ||
}; | ||
for (var n = 0; n < analytics.methods.length; n++) { | ||
var key = analytics.methods[n]; | ||
analytics[key] = analytics.factory(key); | ||
} | ||
})(); | ||
</script> | ||
|
||
<!-- Segment Consent Manager --> | ||
<script> | ||
window.consentManagerConfig = function(exports) { | ||
var React = exports.React; | ||
var inEU = exports.inEU; | ||
|
||
var bannerContent = React.createElement( | ||
'span', | ||
null, | ||
'We use cookies (and other similar technologies) to collect data to improve your experience on our site. By using our website, you՚re agreeing to the collection of data as described in our', | ||
' ', | ||
React.createElement( | ||
'a', | ||
{ href: '/privacy/', target: '_blank' }, | ||
'Privacy Policy' | ||
), | ||
'.' | ||
) | ||
var bannerSubContent = React.createElement( | ||
'div', | ||
{ class: "manage-cookies-btn" }, | ||
'Manage cookies' | ||
) | ||
//var bannerSubContent = 'You can change your preferences at any time.' | ||
var preferencesDialogTitle = 'Website Data Collection Preferences' | ||
var preferencesDialogContent = | ||
'We use data collected by cookies and JavaScript libraries to improve your browsing experience, analyze site traffic, deliver personalized advertisements, and increase the overall performance of our site.' | ||
var cancelDialogTitle = 'Are you sure you want to cancel?' | ||
var cancelDialogContent = | ||
'Your preferences have not been saved. By continuing to use our website, you are agreeing to our Website Data Collection Policy.' | ||
|
||
return { | ||
container: '#segment-consent-manager', | ||
writeKey: 'UK90Ofwacetj5VCPJ7cUgkbNcKLSHO3u', | ||
bannerContent: bannerContent, | ||
bannerSubContent: bannerSubContent, | ||
preferencesDialogTitle: preferencesDialogTitle, | ||
preferencesDialogContent: preferencesDialogContent, | ||
cancelDialogTitle: cancelDialogTitle, | ||
cancelDialogContent: cancelDialogContent, | ||
shouldRequireConsent: () => true, | ||
closeBehavior: exports.inEU() ? "dismiss" : "accept", | ||
bannerTextColor: "black", | ||
analytics.load = function (key, n) { | ||
var t = document.createElement("script"); | ||
t.type = "text/javascript"; | ||
t.async = !0; | ||
t.setAttribute("data-global-segment-analytics-key", i); | ||
t.src = "https://cdn.segment.com/analytics.js/v1/" + key + "/analytics.min.js"; | ||
var r = document.getElementsByTagName("script")[0]; | ||
r.parentNode.insertBefore(t, r); | ||
analytics._loadOptions = n; | ||
}; | ||
analytics._writeKey = segmentWriteKey; | ||
analytics.SNIPPET_VERSION = "5.2.0"; | ||
analytics.load(segmentWriteKey); | ||
analytics.page(); | ||
} | ||
})(); | ||
</script> | ||
|
||
<!-- Segment Consent Manager --> | ||
<script> | ||
window.consentManagerConfig = function(exports) { | ||
var React = exports.React; | ||
var inEU = exports.inEU; | ||
|
||
var bannerContent = React.createElement( | ||
'span', | ||
null, | ||
'We use cookies (and other similar technologies) to collect data to improve your experience on our site. By using our website, you՚re agreeing to the collection of data as described in our', | ||
' ', | ||
React.createElement( | ||
'a', | ||
{ href: '/privacy/', target: '_blank' }, | ||
'Privacy Policy' | ||
), | ||
'.' | ||
) | ||
var bannerSubContent = React.createElement( | ||
'div', | ||
{ class: "manage-cookies-btn" }, | ||
'Manage cookies' | ||
) | ||
//var bannerSubContent = 'You can change your preferences at any time.' | ||
var preferencesDialogTitle = 'Website Data Collection Preferences' | ||
var preferencesDialogContent = | ||
'We use data collected by cookies and JavaScript libraries to improve your browsing experience, analyze site traffic, deliver personalized advertisements, and increase the overall performance of our site.' | ||
var cancelDialogTitle = 'Are you sure you want to cancel?' | ||
var cancelDialogContent = | ||
'Your preferences have not been saved. By continuing to use our website, you are agreeing to our Website Data Collection Policy.' | ||
|
||
return { | ||
container: '#segment-consent-manager', | ||
writeKey: segmentWriteKey, | ||
bannerContent: bannerContent, | ||
bannerSubContent: bannerSubContent, | ||
preferencesDialogTitle: preferencesDialogTitle, | ||
preferencesDialogContent: preferencesDialogContent, | ||
cancelDialogTitle: cancelDialogTitle, | ||
cancelDialogContent: cancelDialogContent, | ||
shouldRequireConsent: () => true, | ||
closeBehavior: exports.inEU() ? "dismiss" : "accept", | ||
bannerTextColor: "black", | ||
} | ||
</script> | ||
} | ||
</script> | ||
|
||
<script | ||
src="https://unpkg.com/@segment/[email protected]/standalone/consent-manager.js" | ||
defer | ||
<script | ||
src="https://unpkg.com/@segment/[email protected]/standalone/consent-manager.js" | ||
defer | ||
></script> | ||
|
||
<script async | ||
data-api-host="https://cdn.growthbook.io" | ||
data-client-key="sdk-0aUDa6bDbQqms3aJ" | ||
src="https://cdn.jsdelivr.net/npm/@growthbook/growthbook/dist/bundles/auto.min.js" | ||
></script> | ||
|
||
{{- if eq hugo.Environment "production" }} | ||
<!-- Clearbit snippet --> | ||
<script src="https://tag.clearbitscripts.com/v1/pk_54e7d7c428c6d5e79098374d93a7b333/tags.js" referrerpolicy="strict-origin-when-cross-origin"></script> | ||
|
||
<!-- Facebook Domain Verification --> | ||
<meta name="facebook-domain-verification" content="phlf6qes2bxa9ufzk8zt2es0qivg8j" /> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters