Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add Amplitude tracking script #6810

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion docs/themes/v2/layout/layout.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,44 @@
<% } %>

<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js" defer></script>

<script id="amplitude-init">
window.addEventListener("message", initAmplitude, false);
function initAmplitude(event) {
if (event.origin !== "https://humansignal.com") {
return;
}
if (!'deviceId' in event.data) {
console.log('unexpected event data', event.data);
return;
}

const opts = {
defaultTracking: {
attribution: true,
pageViews: true,
sessions: true,
formInteractions: true,
fileDownloads: true,
},
deviceId: event.data.deviceId,
};

// prettier-ignore
!function(){"use strict";!function(e,t){var r=e.amplitude||{_q:[],_iq:{}};if(r.invoked)e.console&&console.error&&console.error("Amplitude snippet has been loaded.");else{var n=function(e,t){e.prototype[t]=function(){return this._q.push({name:t,args:Array.prototype.slice.call(arguments,0)}),this}},o=function(e,t,r){return function(n){e._q.push({name:t,args:Array.prototype.slice.call(r,0),resolve:n})}},s=function(e,t,r){e._q.push({name:t,args:Array.prototype.slice.call(r,0)})},i=function(e,t,r){e[t]=function(){if(r)return{promise:new Promise(o(e,t,Array.prototype.slice.call(arguments)))};s(e,t,Array.prototype.slice.call(arguments))}},a=function(e){for(var t=0;t<g.length;t++)i(e,g[t],!1);for(var r=0;r<m.length;r++)i(e,m[r],!0)};r.invoked=!0;var c=t.createElement("script");c.type="text/javascript",c.integrity="sha384-r58GovPc8jo7o9PFd/Y8xHwOiockvJvuIBZZqsA7I8EzliMj0Pe0Sbx7Ti2ClxDD",c.crossOrigin="anonymous",c.async=!0,c.src="https://cdn.amplitude.com/libs/analytics-browser-2.8.0-min.js.gz",c.onload=function(){e.amplitude.runQueuedFunctions||console.log("[Amplitude] Error: could not load SDK")};var u=t.getElementsByTagName("script")[0];u.parentNode.insertBefore(c,u);for(var l=function(){return this._q=[],this},p=["add","append","clearAll","prepend","set","setOnce","unset","preInsert","postInsert","remove","getUserProperties"],d=0;d<p.length;d++)n(l,p[d]);r.Identify=l;for(var v=function(){return this._q=[],this},f=["getEventProperties","setProductId","setQuantity","setPrice","setRevenue","setRevenueType","setEventProperties"],y=0;y<f.length;y++)n(v,f[y]);r.Revenue=v;var g=["getDeviceId","setDeviceId","getSessionId","setSessionId","getUserId","setUserId","setOptOut","setTransport","reset","extendSession"],m=["init","add","remove","track","logEvent","identify","groupIdentify","setGroup","revenue","flush"];a(r),r.createInstance=function(e){return r._iq[e]={_q:[]},a(r._iq[e]),r._iq[e]},e.amplitude=r}}(window,document)}();
amplitude.init("b31f0f12b3309671ac50471a820cad8c", opts).promise.then(() => console.log('initialized amplitude with device id', amplitude.getDeviceId()));

}
</script>
</head>
<body class="<%- 'page-tier-' + theme.tier %>">



<% if(isEnterpriseTheme) {%>
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-K6H522B"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<% } else { %>
<iframe src="https://humansignal.com/amplitude/" style="display: none;"></iframe>
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-TZ3RQGX"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<% } %>
Expand Down
Loading