Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Google Analytics for Salesforce
// hide sidebar component that embedded this javascript
$("h2:contains('Google Analytics')").parent().parent().hide();
// Google Universal Analytics (provided by google)
(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');
// Our analytics tracking id for salesforce production.
// We also enabled cross-domain linking plugins to try
// and handle that salesforce uses multiple sub-domains
// to render standard and visualforce content; we don't
// want the bounce arounds to be treated as separate "users"
// in the analytics reporting.
ga('create', 'UA-xxx', 'auto', {
'allowLinker': true
});
ga('require', 'linkid', 'linkid.js');
ga('require', 'linker');
ga('linker:autoLink', [/YOURDOMAIN(\.|--)(.)*\.(salesforce|force)\.com/]);
ga('send', 'pageview');
@douglascayers

This comment has been minimized.

Copy link
Owner Author

@douglascayers douglascayers commented Mar 24, 2015

Snippet for blog post https://douglascayers.wordpress.com/2014/08/17/salesforce-integrating-google-analytics/

  • Change UA-xxx on line 16 with your google analytics tracking code.
  • Change YOURDOMAIN on line 21 with your salesforce custom domain name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment