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

5.6K members online now
5.6K 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

Analytics.JS is not working properly with my website.

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Dear All,


We have an e-commerce site:"" for which we were using Google Analytics-ga.js but recently we tried to upgrade it to Analytics.JS to track the e-commerce activities and events in the site but, to my regret, the new code does not worked and the page does not loaded while updating in the development server(staging site). I believe, the new code is not compatible with my site.


So, please help me understand, how can I fix it and get it done as I have to track the shipping, billing and cart activities in the site. Moreover, Google Analytics itself recommend to use Analytics.JS instead of Ga.JS. 

We are currently using the below JS code:


<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxxxx-1']);

(function() {
var ga = document.createElement('script'); ga.type =
'text/javascript'; ga.async = true;
ga.src=('https:' == document.location.protocol ? 'https://ssl' : 'http://www' ) + '';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);


And now we want to replace it with the new code which is:

(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

ga('create', 'UA-xxxxxxxx-1', 'auto');
ga('send', 'pageview');


Please help us fix the issue.




1 Expert replyverified_user

Analytics.JS is not working properly with my website.

Rising Star
# 2
Rising Star

Hi John,


Analytics.js is not the problem.  You may have some sort of dependency on the ga.js code.  That said, you'll have to have your developers go through and check. 


Lastly, you could deploy GA via Google Tag Manager instead.




Theo Bennett



Analytics Evangelist at MoreVisibility | Contact Me
Connect on LinkedIn