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:


(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
ga('create', 'UA-1111111-1', 'auto');
ga('set', {
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
Response by poster: Meant to type worth noting....*******
posted by cheero at 11:15 AM on November 14, 2017

Best answer: 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=" - 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, 2017

Response by poster: @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

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, 2017

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

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

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

« Older How to adjust scroll distance in browsers?   |   Facebook anxiety Newer »
This thread is closed to new comments.