Cheok Yan Cheng
Cheok Yan Cheng

Reputation: 42806

Migrate pageTracker._trackPageview to Google Universal Analytics

Previously, I'm using traditional ga.js to track the visitors who click on a link.

<a href="donation.html" onClick="javascript: pageTracker._trackPageview('/donate');">donating</a>

However, I'm just migrating to Google Universal Analytics.

<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-43627934-1', 'jstock.org');
  ga('send', 'pageview');

</script>

What is the proper way to perform equivalent pageTracker._trackPageview?

Upvotes: 3

Views: 1928

Answers (2)

Arthur Alvim
Arthur Alvim

Reputation: 1054

Basically,

ga('send', 'pageview', 'page path');

Check out this link for migration examples:

https://developers.google.com/analytics/devguides/collection/upgrade/reference/gajs-analyticsjs

Upvotes: 2

Lior Asta
Lior Asta

Reputation: 121

ga('send', 'pageview', '/my-overridden-page?id=1');

Upvotes: 2

Related Questions