AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
4K members online now
4K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Google Analytics tracking code not working

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Our Google Analytics Tracking Code differres slightly from the tracking code attached to the website in that the former has https and the latter doesn't have it. There are issues with tracking as well which I posted a while ago. The Web Developer says its correct as our site has been built on a Magento framework. I want clarification on this. Thanks  

 

<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-xxxxxxxx-1', 'auto');
ga('send', 'pageview');

</script>

 

 

The tracking code on the website is as follows:

 

</script>
 <!-- BEGIN GOOGLE UNIVERSAL ANALYTICS CODE -->
 <script type="text/javascript">
 //<![CDATA[
 (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-1', 'auto');
  
 ga('send', 'pageview');
  
 //]]>
 </script>
1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Simplynatural D
June 2016

Re: Google Analytics tracking code not working

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭
Hi
When I posted the tracking code in Google Analytics and whats on the website as a question in Google community a message appeared saying "your post has been changed brcause invalid HTML was found in the message body. The invalid HTML has been removed". As a result whats appearing in the question is the corrected version. I'm unable to trace where it was corrected. I would like to know where this invalid HTML appearing. Thanks

The Tracking code in Google Analytics is as follows.

&lt;script&gt;
(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-xxxxxxxx-1', 'auto');
ga('send', 'pageview');

&lt;/script&gt;

The tracking code on the website is as follows:

&lt;/script&gt;
<!-- BEGIN GOOGLE UNIVERSAL ANALYTICS CODE -->
&lt;script type="text/javascript">
//<![CDATA[
(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-75803679-1', 'auto');

ga('send', 'pageview');

//]]>
&lt;/script&gt;




View solution in original post

Re: Google Analytics tracking code not working

Top Contributor
# 2
Top Contributor
Hi,

Your code is correct, both the https version and the version without https. You can check if your tracking tag is working using the Google Tag Assistant or the GA debugger Chrome extension. In Google Analytics check if you are receiving data using an unfiltered view. Hope this helps.

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: Google Analytics tracking code not working

Follower ✭ ☆ ☆
# 3
Follower ✭ ☆ ☆
Hi Simplynatural D:
One other item that you may need to fix is the tracking code "UA-xxxxxxxx-1" has to have the value from your Google Analytics web property. In the Admin click on Web Property -> Tracking Info -> Tracking Code to see the unique UA code for your web property.
Best,
Jay
Marked as Best Answer.
Solution
Accepted by topic author Simplynatural D
June 2016

Re: Google Analytics tracking code not working

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭
Hi
When I posted the tracking code in Google Analytics and whats on the website as a question in Google community a message appeared saying "your post has been changed brcause invalid HTML was found in the message body. The invalid HTML has been removed". As a result whats appearing in the question is the corrected version. I'm unable to trace where it was corrected. I would like to know where this invalid HTML appearing. Thanks

The Tracking code in Google Analytics is as follows.

&lt;script&gt;
(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-xxxxxxxx-1', 'auto');
ga('send', 'pageview');

&lt;/script&gt;

The tracking code on the website is as follows:

&lt;/script&gt;
<!-- BEGIN GOOGLE UNIVERSAL ANALYTICS CODE -->
&lt;script type="text/javascript">
//<![CDATA[
(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-75803679-1', 'auto');

ga('send', 'pageview');

//]]>
&lt;/script&gt;