Google Analytics stopped working. Code is on site.
November 14, 2017 11:14 AM   Subscribe

Hi All, Our Google Analytics stopped working this Monday at exactly 00:00 -- completely flat. I ran a GA debugger and tag assistant and they both show that tracking code is placed correctly. Here's what we did 1. We first updated Google Analytics from http to https on View Settings (3 column) 2. Day later when we saw that GA stopped working, we also updated Property Settings (2nd column) from http to https Did this make it stop working? I thought https was best practice for setting up GA but perhaps it was done incorrectly. How do I remedy this so GA works again? Thanks for your help!

Worth nothing:

The site was using the following tracking code:


<>

(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-1111111-1', 'auto');
ga('set', {
'dimension1':'[[!+mkto.Email:default=`Anonymous`]]',
'dimension2':'[[!+mkto.Industry:default=`Unknown`]]',
});
ga('send', 'pageview');


But now I see that Google Analytics is telling us to use a more simpler code:

<>


window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'UA-1111111-1');


Very confused over this! I almost think the solution is in front of me but it isn't. I tested both old and new tracking codes.. nothing got recorded unless new code needs 24 hours or more?

posted by cheero to Computers & Internet (5 answers total) 1 user marked this as a favorite
 
Meant to type worth noting....*******
posted by cheero at 11:15 AM on November 14


You don't need to use the new gtag, analytics.js will still be supported for a while, it just has some new advantages over analytics.js.

That said, looks like you're missing some elements of the gtag code per this transition doc

Specifically you're missing this part from the beginning of the script (i.e. the part with async src="https://www.googletagmanager.com/gtag/js?id=GA_TRACKING_ID - i can't paste it here as it's getting stripped out from the commenting box).

Seperately you need to also be sending your pageviews as events now, i.e.

gtag('event', 'page_view', { 'send_to': 'GA_TRACKING_ID' });

Otherwise you're not doing anything besides activating the snippet and not sending any info into it.

http vs https shouldn't be impacting anything - likely just the code that needs updating.
posted by jourman2 at 12:18 PM on November 14


@jourman2 -- Thanks for your help but I think that was just MetaFilter stripping down the GA code.

I uploaded it here as a photo so you can see it better https://imgur.com/a/zyiSF

Top screenshot is how view-source looks on our site.

Second screenshot is how we've always used this GA tracking code. It simply flat-lined on Sunday at 00:00.

Any further tips?

Thanks again!
posted by cheero at 1:07 PM on November 14


Just installed Google Tag Assistant, it's flagging our Google Analytics as Missing HTTP Response.

https://support.google.com/tagassistant/answer/3059154#http_response

but still not sure how this could be if nothing was modified.
posted by cheero at 1:15 PM on November 14


sent you a mefi mail
posted by jourman2 at 1:54 PM on November 14


« Older How to adjust scroll distance in browsers?   |   Facebook anxiety Newer »

You are not logged in, either login or create an account to post comments