gtm.js and analytics.js are not loading with every page load - google-analytics

Since evening of last Wednesday (March 15, 2017) I have noticed that the google analytics script is not being requested by my website consistently. When the script does load, the tags are not firing - for example for button clicks.
Is anyone else having this issue? I have searched around for threads regarding any malfunction on Google's side and could not find any. Google recently had an issue with their captcha which is why I am thinking this is an issue on their side.
To note, the site is built on a CMS and the tag manager code snippet is inherited on every page. This snippet has not been altered in the time surrounding March 15th.
Edit: Moving the code snippet from head to body creates consistent behaviour - gtm.js and analytics.js are loading and the tags are firing and registering in GA.

Check for not using dataLayer = [{...}] declaration after script part of container snippet in your pages code. This declaration should be used only before container snippet.

First thing to check, which you may have already done, is the position of the two code snippets used for implementation. I always position the <script> tag first in the <head>. Also, make sure the <noscript> tag is the first tag rendered in the <body>.
I had a similar issue once. My tags would inconsistently fire. After checking the console log, I found that JQuery was being declared toward the bottom of the <body>. When I moved the JQuery tag to the <head>, the issue was resolved. I can't imagine that you're issue is related, because my issue was due to a mistake by a developer. Nonetheless, check your console log to see if you notice any errors. It may help you determine the root of the problem.
One other thing to try is the Tag Assistant Chrome extension. Run it on your website, and it will run checks on your implementation.
Hope this helps! Let me know if you have further questions.

Related

How to check for live issues with google tag manager?

Previously working code that downloads a csv file from our site, now fails. Chrome, Safari and Edge don't display anything helpful except "Blob Blocked", but Firefox shows a stack trace;
Uncaught TypeError: Location.href setter: Access to 'blob:http://oursite.test/7e283bab-e48c-a942-928c-fae0907fdc82' from script denied.
Then a stack dump from googletagmanager
This appears to be a fault in the tagmanager code introduced in the last couple of weeks.
The fault appears in all browsers and is resolved immediately by commenting out the tag manager. The problem reported by a customer on the production system, and then found on both staging and locally. The customer advised they had used the export function successfully 2 weeks ago.
The question really is, do Google maintain a public facing issues log for things like the tag manager?
It's not about GTM as a library really, it's about poor user implementation. It's not up to Google to check for user-introduced conflicts with the rest of the site's functionality.
What you could do is go to GTM, and see what has been released in the past two weeks. Inspect things and look for anything that could interfere with the site's functionality. At the same time - do the opposite, see all the front-end changes introduced during this time frame by the web-dev team.
Things to watch for is mostly unclosured JS deployed in custom HTML tags. junior GTM implementation specialists like to use the global space, taking the global variables, often after the page is loaded, thus overwriting front-end's variables.
Sometimes, people would deploy minified unclosured code to the DOM, thus chaotically taking short var names. To the same end.
This is likely the easiest and most common way for GTM to break front-end. There definitely still are many ways to do so besides this though.
If this doesn't help, there's another easy way to debug it: make a new workspace from Default (or whatever is live), go into the preview mode and confirm that the issue still happens. Now start disabling newest created fired tags one by one and pinpoint which one causes the issue.
Let us know what it was.
Solution was to replace the previous tag manager code with the latest recommended snippet

How does custom HTML code work in Google Tag Manager?

Pretty new here, so sorry if the post isn't clear at first!
I'm trying to get a Custom HTML Tag to work from Google Tag Manager. The tag fires just fine, but the JS code inside the tag doesn't seem to do anything. It's supposed to update an Adroll conversion, but nothing happens.
I'm more wondering if this type of JS would even work in GTM? Like the fact that it uses a specific adroll function, how would that even work without access to a larger library?
<script> try{__adroll.track("pageView", {"segment_name":"eea7cf78"})
} catch(err) {}
</script>
how would that even work without access to a larger library?
It would not. If you have not loaded a library that defines an _adroll object with at least a track method, then this will give an error.
You probably cannot see this error because of the try/catch block. The idea behind try/catch is that you can prevent a script from going into an undefined state bey handling errors in the catch branch in a controlled manner.
In this case however, it is used merely to hide an error. The problem with that is that now you do not know what is wrong :-). Error messages are useful, and suppressing them is not.
There should be an accompanying tracking library, that you can either load via a script tag in the same custom tag, in another custom tag that fires before your tracking tag (best done via tag sequencing), or ideally Adroll would provide a custom GTM template for their tag. At least their support should provide instructions where to get their tracking library.
Also remove the try/catch, since it does nothing but to obscure a problem that should be fixed (and also creates a performance hit in the process).

Google Tag manager not firing the collect url

I am fairly new to GTM and trying to figure out something here.
This is the url where i have set up gtm:
http://pizza.de/order/testshop/5283/index.htm
If you see at console, dataLayer is correctly set. So there is no problem with dataLayer, however i don't see the collect.js url firing. I am very sure that the configuration is correct but not able to figure out why the dataLayer is not being pushed to the server.
Any help will with greatly appreciated.
Move your dataLayer.push code to come before the GTM container tag. You are pushing to the dataLayer afterwards, so the GTM container is not able to use it.
From this:https://developers.google.com/tag-manager/devguide?hl=en
Variables pushed to the data layer (i.e. using dataLayer.push()) after the container snippet will not be able to fire tags on page loads with a matching condition.
#nyuen, was for responding late. Was AFK. Unfortunately, that didn't help. I made a small application running on localhost and tried to create the same scenario.
Variables pushed to the data layer (i.e. using dataLayer.push()) after the container snippet will not be able to fire tags on page loads with a matching condition.
The above is correct, but however i realized that it still fires no matter where you place the dataLayer, but its better to follow the documentation.
What I realized is that, gtm.js is responsible to fire analytics.js and analytics.js is responsible to fire the events. In my case, due to some unknown reason, analytics.js was not loading at all. So I had to inject this script and then the events started firing.

How to run Google Experiment within Google Tag Manager

I have been trying to get this to work for sometime and there seems to be very little information on how this works.
First, I would like to say that I tried the below method to get it working, so please read this before posting a solution.
What I tried:
I added the google analytics experiment code in a custom HTML block and had it fire only of the original page as stated by google. This doesn't work and seems to create a loop for users. A white page appears when users get to the experiment pages.
Does anyone know how to get this to work? Much appreciated
The Javascript versions of Google Content Experiments are not actually supported in GTM at the moment (they have do do either redirects or change the site on the fly and since it's hard to say in advance at which point during page load the tags fire, and it which order, this does not work very well - in the very best case the original page would load completely before the visitor is redirected to a variation).
The features page for GTM lists A/b testing tags as "coming soon" but does so since at least a year ago, so I wouldn't hold my breath.
However you can do variations serverside (you'd have to implement your own logic to display the proper variation to each users) and pass and experiment id and the variation number to GA via GTM. I do not think there is another (reliable) way to do this, at least not yet. If you need to do it with javascript you should add the experiment scripts to the page code instead of deploying them via tag managemement.
Having said that, there are descriptions for hacking around the GTM limitations using the Experiments Javascript API and some jQuery (here is one). When Google says that something is "not supported" it might just mean they didn't want to test all possible edge cases and err on the safe side. So you if you absolutely have to use GTM for Content Experiments you would have to test if something like this would work for you.
I hope that I understand your problem well. If yes, you can use Google Optimize instead of Google Experiment. The Google Optimize works with Google Tag Manager by default.
Here's what worked for me
For the pages in the Experiment, I implemented Google Analytics the "old fashioned way" with analytics.js instead of GTM.
I tested (with Realtime analytics) this and the Experiment page and the Google Tag Pages both report data.
I did post asking if there might be conflicts from ths.
It's possible to modify the Google Tag Manager (GTM) snippet to run synchronously by removing the j.async=true; line and placing it at the top of your page, immediately after the opening <head> element. Like so:
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXX');</script>
<!-- End Google Tag Manager -->
You can also retain support for users without Javascript by inserting the <iframe> part of the code in the original location specified by GTM (after your opening <body> element).
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXX"
height="0" width="0" style="display:none;visibility:hidden"></iframe</noscript>
It's then possible to insert the Google Analytics Experiments code as a Custom HTML tag in GTM. Just make sure you check the 'support document.write()' checkbox.
Just don't forget to update GTM-XXXX with your container ID.

Game in google earth plugin crashes occasionally

I have created a little flight simulator based on milktruck demo. The problem is that the plugin crashes every couple of refreshes. I have no idea why that is. It happens on all browsers
You can see the game here
http://www.stepupforisrael.com/plane-game/0205/Mingame.htm
Any clue will be welcome....
I see, the issue is that after a few refreshes you get the error ERR_BRIDGE_OTHER_SIDE_PROBLEM and the detail is bad status
I believe this is a bug with how you are loading the plug-in itself - I can reproduce it using a very basic set up. Also, It looks as if there is already a bug report for it here.
http://code.google.com/p/earth-api-samples/issues/detail?id=736
Form reading around, and testing, it appears that loading the plug-in using the Google Loader resolves the issue. To do this.
Firstly, remove the onload 'init' call from the body element.
So that
<body onload='init();' onunload="//GUnload()">
becomes
<body onunload="GUnload()">
Then use the Google loader callback to handle the initialization. To do that place this line at the end of your script block, right before the closing element.
google.setOnLoadCallback(init);
My thinking is that the onload event occurs immediately after a page is loaded. However, sometimes the plugin has not finished authentication when this event occurs, hence the intermittent error. You can read more about this here: https://groups.google.com/forum/?fromgroups#!topic/google-earth-browser-plugin/vvXKanCJbJU
We had our own piece of pain with that error and we used solution described in a different answer (GUnload etc) - without success. The problem was solved when we moved our code from some murky hosting we used - to Amazon EC2. The error stopped immediately. Was it caused by a timeout between our original host and Google servers? We don't know anything except what we did saved us...

Resources