Skip to content

Instantly share code, notes, and snippets.

@johnnyopao
Last active December 15, 2022 11:43
Show Gist options
  • Save johnnyopao/0537dd00827202cc7387 to your computer and use it in GitHub Desktop.
Save johnnyopao/0537dd00827202cc7387 to your computer and use it in GitHub Desktop.
Track each variant with Universal Analytics

Tracking the different variants using Google analytics requires a slight modification of your tracking script

Replace the line below in your Google Analytics script

ga('send', 'pageview');

with this

ga('send', 'pageview', document.location.pathname + window.ub.page.variantId + window.location.search);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment