: Send pageview with Analytics.js to a second account Using Analytics.js: <script> (function (i, s, o, g, r, a, m) { i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function
Using Analytics.js:
<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-1234567-1', 'auto');
ga('send', 'pageview');
</script>
Given a second account UA-ZZZZZZZ-X, how would I push a page view event to this account?
I've tried just adding:
ga('create', 'UA-ZZZZZZZ-X', 'auto');
ga('send', 'pageview');
And the end, but it doesn't appear to be logging the views. In the old version you would do:
_gaq.push( ['app._setAccount', "UA-ZZZZZZZ-X" ] );
_gaq.push( ['app._trackPageview' ] );
But can't seem to get it working with analytics.js!
More posts by @Pope3001725
1 Comments
Sorted by latest first Latest Oldest Best
If you are using multiple trackers, then you need to name your trackers (or at least one of the two, but better to name both so there's no ambiguity).
Much like the Classic (_gaq) code you've posted, you would do the same with the Universal trackers and provide the name along with the method:
// tracker 1 named "someName"
ga('create', 'UA-ZZZZZZZ-X', 'auto', 'someName');
ga('someName.send', 'pageview')
// tracker 2 named "anotherName"
ga('create', 'UA-ZZZZZZZ-Y', 'auto', 'anotherName');
ga('anotherName.send', 'pageview')
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.