admin管理员组文章数量:1343989
I'm having problems migrating from analytics.js to gtag.js. The issue is I can't make virtual pageviews work. How to replicate the following analytics.js code in gtag.js?
ga('set', 'page', path);
ga('send', 'pageview');
This code is in the a tag's onclick event.
This is a single page website which doesn't change the url when you click links.
I'm having problems migrating from analytics.js to gtag.js. The issue is I can't make virtual pageviews work. How to replicate the following analytics.js code in gtag.js?
ga('set', 'page', path);
ga('send', 'pageview');
This code is in the a tag's onclick event.
This is a single page website which doesn't change the url when you click links.
Share Improve this question asked Jan 24, 2018 at 21:42 DBalazsDBalazs 1312 silver badges11 bronze badges 1- Well you didn’t show how you are trying to send using gtag. So here is how to switch from ga to gtag. – James Commented Jan 24, 2018 at 21:59
1 Answer
Reset to default 11Your example code:
ga('set', 'page', path);
ga('send', 'pageview');
would bee:
gtag('config', 'UA-XXXXXXXXX-1', {'page_path': path});
Where 'UA-XXXXXXXXX-1'
would be your google analytics tracking id.
Explained here.
本文标签: javascriptMigrate virtual pageviews to gtagjsStack Overflow
版权声明:本文标题:javascript - Migrate virtual pageviews to gtag.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743735335a2529904.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论