Reputation: 884
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?
Upvotes: 8
Views: 4064
Reputation: 21
FYI: Universal Analytics is out of Beta testing and Enhanced Link Attribution is now supported:
https://support.google.com/analytics/answer/2558867?hl=en
Upvotes: 2
Reputation: 122
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.
Upvotes: 6
Reputation: 1
For your reference the Universal Analytics is, or does support, asyncronous mode. You can see it in the Universal JS code third line down under the "script" tag "a.async=1;".
You can also run both the standard GA code and Universal at the same time. Just setup a separate property for the Universal code and make sure to change the object name "ga" that you see on the fourth line "//www.google-analytics.com/analytics.js','ga')" to say "gau" (just has to be unique on the page for scripts). Then use "gau(" instead of "ga(" for setting things, etc. Remember this is just for the Universal code not the standard GA.
Once you've done this you can continue to track things using the standard GA and have the Universal GA logging underneath the new property. Once you're happy with things you can switch to using only the Universal one.
Upvotes: 0
Reputation: 153
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.
Upvotes: 3