Add support for gtag.js ( Google Analytics )
-
Hi,
It’s nice that this plugin already provides support for tracking page views in Google Analytics. Though, it doesn’t seem to support the new gtag.js tracking method mentioned here: https://developers.google.com/analytics/devguides/collection/gtagjs/
I added support for gtag.js by creating this code snippet:
$('body').on( 'alnp-post-changed', function( e, post_title, post_url, post_id ) { post_url = post_url.replace(/https?:\/\/[^\/]+/i, ''); gtag('config', 'UA-XXXXXXXX-X', { 'page_title' : post_title, 'page_path': post_url }); });
To make it work, you’ll need to replace UA-XXXXXXXX-X with your own Google Analytics tracking ID.
I think it could be a nice feature to add in the plugin in the future.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Add support for gtag.js ( Google Analytics )’ is closed to new replies.