2

I've pasted the following code immediately after the tag on my layout pages (using ASP.NET MCV Razor layouts, but that wouldn't have an effect, would it?):

<!-- Global Site Tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-111111111-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments)};
  gtag('js', new Date());

  gtag('config', 'UA-111111111-1');
</script>

This is exactly how it appears in the Google Analytics portal, except obviously that's not the real ID.

This code is the very first thing after the head tag, before even the meta tags, although I just read that that's probably not a good idea: https://stackoverflow.com/questions/1987065/what-are-best-practices-to-order-elements-in-head

Google Tag Assistant says I have a non-standard implementation, and the portal has sent me an alert stating that I'm not getting any hits, even though I know I am, and I've used the portal to send test traffic also.

I've got two IP filters on that exclude traffic, which shouldn't matter, and a filter to only look at traffic to the live domain (I've got a duplicate site on another domain for testing that uses the same code base).

The only other thing I can think of is because this site is hosted on Azure, even though I've configured a custom domain, maybe I'm getting no traffic because Google Analytics is seeing the mywebsite.azurewebsites.net domain rather than the custom domain, and the filter is for the custom domain? But that would be a bit odd.

The site has had the analytics code in it for about three days now.

What am I doing wrong?

  • support.google.com/tagassistant/answer/… nonstandard implementation means that the tag assistant doesn't see the snippet in the page even though it detects that some data is being collected. – Stephen Ostermiller Sep 30 '17 at 8:26
  • @StephenOstermiller I'm not using Tag Manager, just Analytics, this is the exact link Tag Assistant suggested: support.google.com/tagassistant/answer/…. But the code is in the page, I've checked it in View Source, and it's exactly the same as the code snippet I'm supposed to use. Some documentation says put the snippet as the final thing in the <head>, I've got it as the first thing, maybe I'll try that and see if it makes any difference. Not sure why it's not working. – nmit026 Sep 30 '17 at 10:22
2

Google Analytics has introduced a new tracking code snippet Global Site Tag gtag.js Last I did some testing with it, Google Tag Assistant had not been updated yet to correctly recognize the new snippet.

As of yesterday, the new tracking code was causing GTA to show a missing/invalid tag id for the GTM tag (even though GTM itself is not installed) and a non-standard implementation msg for the GA tracking.

Which is why the OP is getting borked messages from Google Tag Assistant regarding the tracking code installation.

The new snippet calls some GTM code that is associated with your GA tracking ID (rather than a GTM container code) and bundles Universal analytics.js within it too, also associated with your GA tracking id.

Hopefully Google will update GTA to take the new code syntax into account sooner rather than later.

The OP will keep getting the non-standard implementation message until Google updates Google Tag Assistant to properly recognize the new Global Site Tag gtag.js tracking snippet.

1

The filter was: include only traffic to the hostname that are equal to example.com.

Since my site uses www, this didn't work, because the hostname included www in this case.

Should have read this list of custom filter fields first, which defined exactly what they meant by hostname (a URL hostname): https://support.google.com/analytics/answer/1034380?hl=en

Also see here: http://www.gilliganondata.com/index.php/2012/05/22/the-anatomy-of-a-url-protocol-hostname-path-and-parameters/

Changed the filter to: include only traffic to the hostname that contain example.com.

Now it works, I can see traffic.

Although Google Tag Assistant is still giving me the non-standard implementation warning. Others have said it's buggy, I don't know, will try to fix later.

Update: Putting the Analytics code snippet at the end of the <head> tag instead of at the start makes no difference. Still getting Non-standard implementation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.