Could some explain what does 'www.google-analytics.com/analytics.js' do? I mean how the code works and what are the 2469 lines of code do...
I have seen an explanation of what the code that loads this script do. It is here: Google Analytics Code Explanation. This is useful, but it only explains how the final script gets loaded, not the inner workings of the actual analytics.js file.
Related
If my javascript code attempts to load the Google map API more then 25,000 times in a day then Google will write OverQuotaMapError to the window.console.
See https://developers.google.com/maps/documentation/javascript/error-messages
Is OverQuotaMapError a property or a value in the window.console object?
What is the recommended code to see if this ‘error’ has occurred?
I have a wildland fire map that will likely hit the API load limit later today. When that happens I want to be display an informative message to my users.
Silly me. If you open the google documentation link I posted and scroll to the bottom then you will see a link to advice from Google for how to check for any of these errors via your code.
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.
What people are doing is basically taking the UA-XXXXXX code that you normally get with analytics, and they are generating calls against it. This is skewing my analytics stats. On top of that, in Google WebMaster tools, it's also causing this:
It looks like somehow these pages, with my code on or at least with the generated code on, is making Google Webmaster tools think I have lots of 404's. This can't possibly be good for my rankings.
Anyone know if there is anything you can do to stop this?
Try making async call from your server end using CURL.That way you will never expose your GA code.
I have not implemented it, but it might work as per theory
Since you can filter by custom dimensions you can set a "token" in a custom dimension on every page and filter out any traffic in your view settings that does not include the token.
Obviously this will not help against people who use the code from your website (unless you also implement shahmanthan9s suggestion - which is a lot of work but will give you cleaner data), but it will work against drive-by shooters who randomly select UAIDs to send data to (which is the situation you refer to in your comment).
Which is the best place to put google analytics, the header or footer. Can I put it before the tag or can it be along with the scripts before the closing body tag
both the ga.js version and analytics.js version officially state to put it just before the closing </head> tag. But just between you, me and the fence post, there is no significant difference regardless of where you put it. Some people like putting the whole thing in the head tag. Some people like putting it in the footer. Some people like splitting the code up so that they can more easily have custom code sandwiched inbetween (I personally like this style the best). Each school of thought will claim it's the bestest and other methods are stupidest. The war rages on.
Look at it that way: You implement GA in the footer and a problem occurs. Then you go to a help site and say "I have a problem with my code and btw. I did not implement it according to Googles documentation because I did not feel it was necessary". At that point most people will tell you to fix your code and report back later.
So in the worst case you do not loose anything by doing it right, in the best case you have skipped one annoying step with trouble shooting. Sounds like a no-brainer to me.
To address Crayons argument that it is not necessary to identify partially loading sites (see discussion in the comments to his answer): These will be most likely sites where users exit the page due to the errors, so you want to have them in your tracking (since this will show you where your site needs fixing). Unless all you want is a page counter in which case GA is a bit overfeatured anyway.
(Btw. this is an answer to your question "which is the best place". Should you have meant "Will Google Analytics still track most things if I implement it any-old-where" then the answer is "yes", as Crayon has pointed out).
So, in order to see interests/demographics/etc on google analytics, I need to make a one line change to my tracking script on the website ( https://support.google.com/analytics/answer/2444872?hl=en&utm_id=ad ). So, I simply copied the code and pasted it in my website's base template. Everything works! Realtime analytics, google's debug script gives no errors, but... when I click demographics tab, or any other one requiring the script change, I need to validate the tracking code. When I click that button, nothing happens... Anyone had similar problems?
My website: http://osrodekzdrowiawskale.pl/
I had the same problem; I knew I implemented the code correctly, still the validation didn't work. I hesitated to press skip, though, but it worked when I did! After that, it said on the web page that it will take 24 hours before data reports start to show.
"If you are certain that you’ve made the correct change, you can click Skip validation."
https://support.google.com/analytics/answer/2819948?hl=en-GB (Solution source)
Edit: Just noticed that the question was solved in the comments.
Check again tomorrow. Can take anywhere to 24 hours for demographic data to start populating.