Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Universal Analytics Enhanced Link Atrribution

I'm using UA on our company's in-house software to help understand how our users use it, and part of that is learning what they click when they click and so on.

Enhanced Link Attribution seems to be the best choice for this, but per the Developer Docs:

Tag your page for enhanced link attribution

In order to implement this additional tagging for enhanced link attribution, you have to use the asynchronous version of the Analytics tracking code.

The problem I'm seeing is that currently, I'm using Universal Analytics which uses analytics.js whereas the Asynchronous version of GA uses ga.js. So now I'm confused because the option is available in my property settings in the Admin section in our GA account.

Univeral Analytics

  <script>
    (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-CODE-HERE', 'SITE_URL');
    ga('send', 'pageview');

  </script>

Asynchronous Code

<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXX-X']);
  _gaq.push(['_trackPageview']);

  (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

Since the two versions of GA are not compatible, can I still use Enhanced Link Attribution? If so, what steps would I take? I can't seem to find the answers in the Google Analytics docs related to ELA with UA.

Edit Is it at all possible or advised to use both versions of Google Analytics on the same page/site/property? Assuming I set up another GA property for the standard version and use both JS snippets on the site?

like image 695
DavidScherer Avatar asked Apr 19 '13 14:04

DavidScherer


People also ask

What is enhanced link attribution in Google Analytics?

Enhanced Link Attribution improves the accuracy of your In-Page Analytics report by automatically differentiating between multiple links to the same URL on a single page by using link element IDs.

How do I setup an enhanced link attribution on my website?

Under the Property column, click Property Settings. Now scroll down to the In-Page Analytics section and under Use Enhanced Link Attribution, click the slider button to turn it from off to on.

What is enhanced measurement in ga4?

Enhanced Measurement is a feature in Google Analytics 4 that makes it possible for you to automatically (or auto-magically) collect insights about the actions people take on your website. By enabling the feature in the interface, you can collect more insights into how people engage with your content.


3 Answers

To answer the original question: No, enhanced link attribution is not yet supported by Universal Analytics. Though this and many other features will be rolled out soon enough. Universal Analytics is still very beta, but it's been established that this is the future for google analytics.

Yes, the new code is asynchronous just like the old code, and I really couldn't imagine a situation where you would want to turn this off. Asynchronous loading in this case means that when the analytics javascript fires, your web page continues loading regardless of whether the javascript has finished loading or not. Before the asynchronous snippet update, it was best practice for the analytics code to be loaded in the footer to prevent the entire page from hanging due to the script not being asynchronous in nature. Though this was changed because on long/slow pages, the user would often interact with the website before the footer/javascript had a chance to load, and in turn caused major discrepancies in the data.

Wikipedia:

In computer programming, asynchronous events are those occurring independently of the main program flow. Asynchronous actions are actions executed in a non-blocking scheme, allowing the main program flow to continue processing.

I also wouldn't suggest changing the object name as Concept Rat suggests, as I believe that would only apply if you were implementing multiple "universal analytics" trackers to different web properties within the same snippet.

https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced#snippet:

Renaming the Global Object

In some cases the ga variable name might already be used by an existing object on your page. To avoid overriding your existing object, you can rename the ga function, for example to __gaTracker. To do this, simply replace the ga parameter in the snippet above:

(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','__gaTracker');

Then you can use __gaTracker instead of ga when calling commands:

__gaTracker('create', 'UA-XXXX-Y'); __gaTracker('send', 'pageview');

If renaming the variable were necessary to load both snippets, I don't believe Google would say this:

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

The analytics.js snippet is part of Universal Analytics, which is currently in public beta. New users should use analytics.js. Existing ga.js users should create a new web property for analytics.js and dual tag their site. It is perfectly safe to include both ga.js and analytics.js snippets on the same page.

Also please note, if you want to try out universal analytics you should run it concurrently with your existing implementation, as they should eventually release a migration tool to remain backwards compatible allowing you to keep your existing data. To be perfectly clear: You should only fully implement universal analytics if you're are creating a brand new account with no existing data in place.

like image 105
nocommit Avatar answered Jan 04 '23 16:01

nocommit


I've been researching this same problem. As of November 2012, Google said the following in response to a support question: "In-Page Analytics support for analytics.js is not yet implemented. This is one of the features we'll be working on and introducing later in the beta. Other features not currently supported include Remarketing and AdSense reporting." As you know, Enhanced Link Attribution is a feature of In-Page Analytics.

I have not found any new references to this issue since that post, so I can only assume they Universal Analytics is still not ready for prime time. If you can, I would try using Asynchronous Code until Universal Analytics is working properly.

like image 21
JohnH Avatar answered Jan 04 '23 16:01

JohnH


FYI: Universal Analytics is out of Beta testing and Enhanced Link Attribution is now supported:

https://support.google.com/analytics/answer/2558867?hl=en

like image 20
Kevin Avatar answered Jan 04 '23 15:01

Kevin