: How do I install Google Tag Manager on Wordpress subdomain for the same Google Analytics that is on my main domain? Basically I have a Heroku app on a main domain and a wordpress blog on
Basically I have a Heroku app on a main domain and a wordpress blog on a subdomain as blog.maindomain.com. I have google tag manager installed on the herokuapp that tracks the main domain.
How am I able to also allow my wordpress to have the same functionality? I want to be able to view all the analytics in a single account.
EDIT: I don't have to use GTM on the wordpress website, just as long as the data is showing on the same GA account.
More posts by @Dunderdale272
2 Comments
Sorted by latest first Latest Oldest Best
There's quite a few different plugins available that help you install Google Tag Manager on your Wordpress website. You can check out just a few of them here:
en-ca.wordpress.org/plugins/search.php?type=term&q=tag+manager
From your question it isn't very clear if you have GTM deployed on wordpress already or not. If not, get it on there via a plugin or by editing the template code to add the GTM code.
GTM Version
As far as getting sudomain.domain.com traffic to appear in the same analytics view, you need to use the same UA code in Tracking ID field of the the pageview tag in GTM and modify one thing. Specifically under More Settings --> Fields to Set add an entry with cookieDomain as the Field Name and auto as the Value. This will cause google to push pageviews to the same Google Analytics Account and event connect the same session since the cookieDomain auto part will cause GTM to set the analytics cookie to the highest domain it can which on sudomain.domain.com will resolve to domain.com
Hardcoded
<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','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXXXX-Y', 'auto');
ga('send', 'pageview');
</script>
The cookieDomain part is in this line ga('create', 'UA-XXXXXXXX-Y', 'auto'); with the UA code being the same you use on the domain.com site.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.