question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

It won't work with Google Tag Manager

See original GitHub issue

In your article Google Analytics is described. Google Tag Manager now replaces Google Analytics and is different. GTM first load a js file. That js file then loads “google-analytics.com/analytics.js”.

However, there’s no difrect link to “google-analytics.com/collect” in analytics.js anymore. Instead there’re different kinds of other links to:

Which ones should be proxied? Which ones not?

How to work with all that now?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:27 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
naddikacommented, Oct 22, 2019

Okay, I’ll double check.

1reaction
ZitRoscommented, Oct 21, 2019

I love you’ve started the issue from one question, and after a lengthy discussion it turns out to be a completely different question ♥ But we’re nailing it!

No. The way Global Site Tag works is different from GTM.

At the first glance, it is not different. Do not state that until you clearly understand the problem ^^

Go load the actual script at “https://www.googletagmanager.com/gtag/js?id=UA-NNNNNN-N” and check if that works the same way Google Tag Manager does. It won’t. And you’ll see what I’ve been talking about.

So I went and checked. Everything works just fine if we ignore SSL errors on localhost. Please remember to always describe what exactly doesn’t work for you, as it takes time to guess every time.

image

Note that on localhost there is no https set up, and, most likely, in your case the script fails because it requests analytics through the secure connection https://localhost/www.google-analytics.com/analytics.js (note https) which is not enabled in NodeJS proxy. Your proxy path-forwarding should handle https forwarding and request the NodeJS proxy via http only. To make it work on localhost, if it’s your case, you can cheat a little with the config file like this:

        specialContentReplace: { // Special regex rules for domains
            "www.googletagmanager.com": [
                {
                    regex: /https/g,
                    replace: "http"
                }
            ],
            "www.google-analytics.com": [
                {
                    regex: /https/g,
                    replace: "http"
                }
            ],

Please describe what exactly doesn’t work for you or was it your case. Hope this helps. Please, describe issues in very much detail, because it takes time to dig in and understand why you asking.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot issues - Tag Manager Help - Google Support
Container snippet problems: The Tag Manager container snippet might be installed incorrectly on your site. Use Tag Assistant to help verify installation.
Read more >
16 Most common Google Tag Manager mistakes
16 Most common Google Tag Manager mistakes · Table of Contents · #1. Viewing the wrong Google tag manager container · #2. Container...
Read more >
5 Ways to Troubleshoot Your Google Tag Manager Installation
1) Write Good Code and Validate Your JavaScript · 2) Use Google Tag Manager's Preview Link to debug in Firefox with Firebug ·...
Read more >
5 Common Google Tag Manager Problems | Advance Metrics
Figure out why your Google Tag Manager tags do not fire by going through our list of common GTM errors and their solution....
Read more >
Google Analytics not working? Here are 21 ways to fix it
Tags not firing: Look at Google Tag Manager preview mode and check if the tag is firing or not. Ensure your tag is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found