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 snippet to use Universal Analytics (analytics.js) instead of ga.js

See original GitHub issue

This is probably still open to debate while Google brings analytics.js out of beta but I’ve tried it on a few websites since it’s release and it is pretty amazing in extra info and tools it brings.

It isn’t really pretty (may be we can hack it to reduce it’s footprint).

More Info: https://developers.google.com/analytics/devguides/collection/analyticsjs/

(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-XXXX-Y');
ga('send', 'pageview');

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:23 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
wamattcommented, May 14, 2013

Furthermore according to Wikipedia, Google Analytics is the most popular analytics program in the world.[1]

If Microsoft Windows happens to be the dominant desktop OS, should software only consider that the use case? Or if Internet Explorer happens to be the most popular browser, should we consider IE specific extensions as sensible? etc.

“Being the most popular” does not seem like a convincing argument.

Sure analytics are useful to beginners, but so is stuff like choosing a webhost or domain registrar. Should we throw that in too?

[1] http://en.wikipedia.org/wiki/Google_Analytics#Popularity

0reactions
alrracommented, Apr 9, 2014
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 >
[UA→GA4] Tips for switching from analytics.js to gtag.js
If you use analytics.js for your current Universal Analytics property, you'll need to add the gtag.js snippet for your new Google Analytics 4...
Read more >
GTAG vs Analytics.js . Which one should you use?
In this guide, you will learn the differences of gtag.js vs analytics.js. Which one should you use and should you migrate to gtag.js?...
Read more >
A Guide to Google Analytics Snippet Versions from 2005 to ...
Google Analytics – Universal Analytics (gtag.js) ... The latest GA snippet is gtag.js, it is not as flexible as using Google Tag Manager...
Read more >
How to Add Google Analytics Tracking to a Website - Chartio
Once you've identified your tracking ID, you'll need to get your tracking code snippet, which can be found on this page as the...
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