The following script is not generating activity when cross-checked in Google Analytics
: Real-Time
section : Content
section --
<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/analytics.js','ga');
ga('create', 'UA-475021xx-x', 'auto');
ga('send', 'pageview');
</script>
where xx-x
masks the real account code.
The script is placed just before </head>
We have upgraded our account to Universal Analytics
. Google tells us that this is the script to use; directly copied and pasted here (with the masked account code).
On the Google Analytics page, the test page is loaded as an ACTIVE PAGE
. I click links on the test page to trigger ga
.
Is there an error in this script? For example, I see on other Stackoverflow posts that 'auto'
is replaced with the real domain
. But I don't see Google instructions to make that substitution.
Am I doing something else wrong?
The following script is not generating activity when cross-checked in Google Analytics
: Real-Time
section : Content
section --
<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-475021xx-x', 'auto');
ga('send', 'pageview');
</script>
where xx-x
masks the real account code.
The script is placed just before </head>
We have upgraded our account to Universal Analytics
. Google tells us that this is the script to use; directly copied and pasted here (with the masked account code).
On the Google Analytics page, the test page is loaded as an ACTIVE PAGE
. I click links on the test page to trigger ga
.
Is there an error in this script? For example, I see on other Stackoverflow posts that 'auto'
is replaced with the real domain
. But I don't see Google instructions to make that substitution.
Am I doing something else wrong?
Share Improve this question asked Sep 5, 2014 at 1:08 Jay GrayJay Gray 1,7263 gold badges20 silver badges38 bronze badges 7- When did you add this bit of code? – Zaenille Commented Sep 5, 2014 at 1:10
- @Mark about 8 hours ago (~ 12:00 CDT) – Jay Gray Commented Sep 5, 2014 at 1:12
- Does the overview (not the real time one) show data? – Zaenille Commented Sep 5, 2014 at 1:13
- @Mark No - just checked. The overview page (with a map) reports: "Right now 0 active users on site" Only the test page has the in-line script. No other page on the site has a Google analytics script. – Jay Gray Commented Sep 5, 2014 at 1:17
- 1 If it is a new Google Analytics account it can take up to 72 hours for data to start showing up. If you just added the code to the website it can take between 24 - 48 hours for it to show up. – Linda Lawton - DaImTo Commented Sep 5, 2014 at 7:42
5 Answers
Reset to default 5I did the same thing as you back then.
Mine started showing data in about 12-24 hours after I put the Google Analytics code.
I suggest waiting for another day then checking if data comes up.
Given that this answer can only be verified until we wait for a certain amount of time, please hold off setting this as the correct answer until then.
For me, the issue was a dunce move. I have the Google Analytics Opt-out Add-on for Chrome enabled.
What I had to do was go to chrome://extensions/, scroll down to the Extension "Google Analytics Opt-out Add-on (by Google)" and uncheck the box that says, "Enable".
I hope this helps someone.
You can check the health of your tag using Google tag assistant, and also check with developer tools whether you can see data being sent to your GA account. Also look in your account under Property > Tracking Info > Tracking Code for the status of your tracking code. But if you are not seeing Real Time data then something could be wrong.
The third parameter in the 'create' method sets the cookie domain. It is optional and with 'auto', it sets the cookie domain to the highest domain level possible. Without it, the cookie domain will be set to the website domain without the www. prefix.
Here is what my issue was. I'm using google analytics with wordpress. I tried configuring google analytics for my website using plugin called Google Analytics Dashboard for WP (GADWP). This plugin generated a google analytics snippet that looks similarly to the one described in the question:
<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-475021xx-x', 'auto');
ga('send', 'pageview');
</script>
However, in Google Analytics console, the suggested snippet looked like this:
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-110984887-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-475021xx-x');
</script>
It looks like this gtag.js is a new format for the google analytics snippet. So I disabled that wordpress plugin and I manually added the script suggested by Google Analytics to the page.
I have recently fixed the same issue. Please login to your admin dashboard and check the filters.
What I did was to make sure my valid host name filter was the correct one.
If you have copied the custom dashboard from another project or if you had an error in the filter then this would be worth your time to check out.
I have placed the value "domain.com" in the included host names filter.
Let me know if this fixed the issue for you.