switch analytics from ga to segment
This commit is contained in:
parent
d2f9fd1afc
commit
b0937ff94d
|
@ -8,7 +8,7 @@ build:
|
|||
--tty \
|
||||
--volume "$(shell pwd):/website" \
|
||||
hashicorp/middleman-hashicorp:${VERSION} \
|
||||
bundle exec middleman build --verbose --clean
|
||||
ENV=production bundle exec middleman build --verbose --clean
|
||||
|
||||
website:
|
||||
@echo "==> Starting website in Docker..."
|
||||
|
|
|
@ -8,6 +8,16 @@ activate :hashicorp do |h|
|
|||
end
|
||||
|
||||
helpers do
|
||||
# Returns a segment tracking ID such that local development is not
|
||||
# tracked to production systems.
|
||||
def segmentId()
|
||||
if (ENV['ENV'] == 'production')
|
||||
'AjXdfmTTk1I9q9dfyePuDFHBrz1tCO3l'
|
||||
else
|
||||
'0EXTgkNx0Ydje2PGXVbRhpKKoe5wtzcE'
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the FQDN of the image URL.
|
||||
#
|
||||
# @param [String] path
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
document.addEventListener('DOMContentLoaded', () => {
|
||||
track('.downloads .download a', el => {
|
||||
return {
|
||||
event: 'Download',
|
||||
category: 'Button',
|
||||
label: `Packer | v${el.href.match(/\/(\d+\.\d+\.\d+)\//)[1]}`
|
||||
}
|
||||
})
|
||||
})
|
|
@ -3,3 +3,6 @@
|
|||
|
||||
//= require hashicorp/mega-nav
|
||||
//= require hashicorp/sidebar
|
||||
//= require hashicorp/analytics
|
||||
|
||||
//= require analytics
|
||||
|
|
|
@ -119,14 +119,16 @@
|
|||
</div>
|
||||
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-43075859-1', 'packer.io');
|
||||
ga('require', 'linkid');
|
||||
ga('send', 'pageview', location.pathname);
|
||||
// ga async load
|
||||
window['GoogleAnalyticsObject'] = 'ga';
|
||||
window['ga'] = window['ga'] || function() {
|
||||
(window['ga'].q = window['ga'].q || []).push(arguments)
|
||||
};
|
||||
// analytics.js
|
||||
!function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t){var e=document.createElement("script");e.type="text/javascript";e.async=!0;e.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)};analytics.SNIPPET_VERSION="4.0.0";
|
||||
analytics.load("<%= segmentId %>");
|
||||
analytics.page();
|
||||
}}();
|
||||
</script>
|
||||
|
||||
<script type="application/ld+json">
|
||||
|
|
Loading…
Reference in New Issue