Google analytics is included in the header, but doesn't work - google-analytics

So I am working on nosleeplessnights.com and have google analytics added to the header. For some reason it doesn't work and tag managers says the script is missing.
<script type="text/javascript">
(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.nosleeplessnights.com/analytics.js','ga');
ga('create', 'UA-35194122-1', 'auto');
ga('send', 'pageview');
</script>
"Missing analytics.js script" Any idea what I'm doing wrong here?

In your snippet you re asking ga to look for the analytics.js script at https://nosleeplessnights.com/analytics.js, try replacing this url in your snippet with the official one : https://www.google-analytics.com/analytics.js

we swapped to gtags which worked. not a real solution, but still - it worked.

Related

Google Tag Manager conflict because in my HTML I have an element with name="ga" and id="ga"?

Is it possible that my GTM code is failing because of some conflict with Google Analytics and an HTML element I have with <input id="ga" name="ga">?
My tag for Google Analytics is:
<style>.async-hide { opacity: 0 !important} </style>
<script>(function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date;
h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')};
(a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c;
})(window,document.documentElement,'async-hide','dataLayer',4000,
{'GTM-XXXXXXXXXXXXX':true});</script>
<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-XXXXXXXXXXXX', 'auto');
ga('send', 'pageview');
</script>
Should I change the 'ga' to something else and it'd still work but without the conflicts?
I found this answer but I'm not sure if it's the same issue, however I'll try to do it (the reason why I don't try and test it by myself is because it will take a lot of time until the marketing team can check it).
Changing the Global GA Object in google tag manager
Yes, it is certainly a cause.
The error it will generate is:
Uncaught TypeError: ga is not a function
You can see it in this JSFiddle (see error in console).
As the answer by Michele Pisani says, it does conflict, and it can be solved with this answer (changing the global function name):
Changing the Global GA Object in google tag manager

google analytics for responsive design

I've started with Google Analytics this year so I'm still learning a lot.
I have stumbled onto this article: http://www.smashingmagazine.com/2014/08/28/responsive-web-design-google-analytics/
And I thought it really interesting but I'm struggling. I implemented it for this website:
http://conversionadvantage.com/
but now my GA stopped tracking; telling me I don't have the code on my website.
Can someone give me pointers please as what I could have done wrong? My code looks like this:
<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-xxxxxxxx-x', 'auto');
ga('require', 'displayfeatures');
ga('send', 'pageview', {
'dimension2': WURFL.complete_device_name,
'dimension4': WURFL.form_factor,
'dimension3': WURFL.is_mobile
});
</script>
I just have different dimensions since nr 1 is taken. The developer also added
<script type="text/javascript" src="//wurfl.io/wurfl.js"></script>
So any thoughts for a newbie?
Thanks in advance!
Wurfl is a script for device detection that is used to determine device name etc. So you need to include this before your pageview calls else the variables will not be set (which will result in a javascript error, hence GA will not track anything).
Device Name and "is_mobile" are not necessary since this is already tracked by Google Analytics.

Do I need any library before adding google analytics to my website?

I have got the google analytics code which is written below
<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', 'xx-xxxxxx-x', 'auto');
ga('send', 'pageview');
</script>
I searched on net a lot but could not find my answer. Do I need any library before adding this code to my web just like we add jQuery library before adding jQuery script.
You can just add that code to your website, place it just before the </head> tag. No extra libraries are needed.
You can just paste the code in right before the </head> tag
Set up the web tracking code:
https://support.google.com/analytics/answer/1008080?hl=en

Analytics Code Not Tracking after 24 hours

I've installed - and I believe I installed right - Google Analytics code yesterday. But still getting "not tracking" message and 0 stats. Can anyone check if there is something wrong?
I don't know if it's allowed to give urls. So, the website is my display name dot com if you want to check.
Here is my head code:
<head>
<meta charset="utf-8">
<title>Babality - Oyunlar, Hileler, Combolar</title>
<meta name="keywords" content="flash oyun, unity oyunları, 3d oyunlar, flash oyunlar, tam ekran oyun, oyun hileleri, oyun comboları, oyun komboları">
<meta name="description" content="domain.com; kaliteli ve eğlenceli oyunların, popüler oyunlara ait hilelerin ve comboların bulunduğu bir web sitesidir.">
<link href="http://domain.com/tyle.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="http://domain.com/jss.js"></script>
<!-- analytics script -->
<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-55572105-1', 'auto');
ga('require', 'displayfeatures');
ga('send', 'pageview');
</script></head>
I've tried some websites that checks if anaytics code works. Every site I tried saw my analytics code working.
I've tried GA Debug extension on Chrome. Can't find any errors.
I can see my code in my pages
I've tried Google Tag Assistant extension on Chrome. It found a Google tag. It was Analytics. And 0 errors.
Bottomline, everything - even Google extension - says nothing wrong. But still not tracking.
EDIT: Did not change anything, did not do anything. Code works now. Seems sometimes 24 hours is not enough. For me, code worked after 30 hours.
After you have installed the tracking code, you will need to wait at least 24 hours for stats to show up in your standard reports. What you can do is to check in Real-time reports to see if you see hits for you own simultaneous visits. If you see data there, then you should only need to wait the aforementioned 24 hours.

Google Analytic tracking code not working / not installed.

The code is visible in "view page source" but GA says "Tracking Not installed". the website is validated for errors with html5.validator.nu and http://validator.w3.org and there is no error. But still couldn't see the "Tracking Installed" not the realtime activity.
<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-40983367-1', 'star-business-directory.com');
ga('send', 'pageview'); </script>
here is my site: star-business-directory.com
The code is implemented correctly. Please check that your property is properly configured to receive Universal Analytics data. If not, then it will not work.
Regarding Universal or Classic Analytics support, you can find this information if you look in the administrative overview, under "Property".
If you look at the top, you can see a property which does NOT have support for Universal Analytics. Please upgrade. If you DO have support for it, you should see a green check sign.
Also, are you looking into the correct account and property? You should be seeing real-time data for the property UA-40983367-1.
The code on your site looks like this:
<script> <!-- type="text/javascript" language="javascript"> -->
(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-40983367-1', 'star-business-directory.com');
ga('send', 'pageview');
</script>
I believe the problem you are having issues with the HTML comment inside the script tag. Try and remove the following code.
<!-- type="text/javascript" language="javascript"> -->

Resources