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.

Update Google Analytics to gtag

See original GitHub issue

I checked that…

  • … the documentation does not mention anything about my idea
  • … to my best knowledge, my idea wouldn’t break something for other users
  • … there are no open or closed issues that are related to my idea

Description

Google has been sending me emails that analytics.js is being replaced by gtag.js and has a new code snip to use it.

Possibly related (although I think they are talking about a different feature, unless Google combined these): https://github.com/squidfunk/mkdocs-material/issues/1914

Use Cases

Anyone receiving the emails to update would stop receiving the emails 😄

Apparently Google lists the selling points as:

  • Future-proof conversion measurement: Benefit from the latest features and integrations as they become available so that you’ll be better equipped to continue measuring conversions accurately if non-Google changes occur.
  • Code-less tag management: Turn measurement features on and off within your Google Analytics account without having to manually change tags on your page.
  • Faster and easier integration: Seamlessly implement and integrate with other Google products, such as Google Ads and Google Optimize.

Screenshots / Mockups

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-#######-#"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-#######-#');
</script>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
squidfunkcommented, Jun 6, 2021

gtag.js support just landed in master and will be released soon. Feedback appreciated. Now, both formats are supported.

Google Analytics

extra:
  analytics:
    provider: google
    property: UA-XXXXXXXX-X

Google Analytics 4 (via gtag.js)

extra:
  analytics:
    provider: google
    property: G-XXXXXXXXXX
2reactions
nemchikcommented, Dec 12, 2020

@squidfunk sorry to necro this, but I am attempting to help a friend setup an mkdocs deployment with google analytics and it appears he is not able to setup anything except Google Analytics V4 which no longer provides a UA-##### and instead seems to require the use of gtags. since new GA users are forced to GA4 and existing users (myself included) are being sent emails from google urging them to upgrade it’s probably a good idea to reconsider this.

P.S. I upgraded one of my less important GA properties to GA4 and it no longer has a UA-##### and now only has the option to use gtags, which seem to give a measurement ID in the format G-ABC123.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrate from analytics.js to gtag.js (Universal Analytics)
This guide walks you through the process of migrating an existing analytics.js Universal Analytics implementation to use gtag.js .
Read more >
Add a Google Analytics 4 property (to a site that already has ...
In Google Analytics, click · In the Account column, make sure that your desired account is selected. · In the Property column, select...
Read more >
How to Upgrade to Google Analytics 4 (GA4)?
Learn how to upgrade to Google Analytics 4. This blog post explains how to upgrade, why to upgrade, and when you should do...
Read more >
How to Install Google Analytics 4 (Updated in 2022 ... - YouTube
Learn how to install Google Analytics 4 with GTAG or Google Tag Manager. Both options are explained. Google Analytics 4 is the latest ......
Read more >
How to upgrade to Google Analytics 4 (2022) - YouTube
Learn how to upgrade from Universal Analytics to Google Analytics 4 (because UA will stop working in 2023). Create a new property, ...
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