Skip to content

Instantly share code, notes, and snippets.

@davidjturnbull
Created November 4, 2015 15:54
Show Gist options
  • Save davidjturnbull/ef1a76528b1ac65d4f9b to your computer and use it in GitHub Desktop.
Save davidjturnbull/ef1a76528b1ac65d4f9b to your computer and use it in GitHub Desktop.
Segment.com - Track: Downloaded File
// Download Link
<a href="http://[FILE PATH GOES HERE eg: mydownload.pdf]" id="filedownload" target="_blank"><em>“My Download</em>”</a>
// File Download Tracking
<script type="text/javascript">
var link = document.getElementById('filedownload');
analytics.trackLink(link, 'Downloaded File', {
fileType: '[TYPE OF FILE eg: pdf]',
fileName: '[NAME OF FILE BEING DOWNLOADED]',
pageTitle: document.title,
pageUrl: location.href
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment