Skip to content

Instantly share code, notes, and snippets.

Created March 24, 2015 14:47
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)
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
// 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');
Copy link

Snippet for blog post

  • 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