Knowledge Base/Urchin Software and Google Analytics

How To Process Google Analytics Data with Angelfish

Angelfish
posted this on Mar 03 06:24 PM

Google Analytics tracking code allows you to store a backup copy of the data Google collects. The backup copy can either be sent to your local web server or to a remote server. Once you have this data, you can process it in Angelfish with the UGA tracking method.

To make this work, you need to add a few lines of JavaScript to your existing Google Analytics tracking code snippet. Setup instructions are below.

 

NEW TO ANGELFISH?

Angelfish is secure, on-premise web analytics software. Learn more here:

http://analytics.angelfishstats.com/

 

Benefits of using Angelfish with GA

GA Backup
Thanks to agency & employee turnover, organizations lose access to Google Analytics with stunning regularity. If you can't access your Google Analytics account, Angelfish will have a "backup" of your data.

Full Visitor Details
Google Analytics doesn't show individual visitor details, but Angelfish does! Angelfish lets you drill down to see full clickpaths, usernames, IP addresses, geographic location, and other details for every visitor to your website.

Extra Information
Angelfish provides information that doesn't exist in Google Analytics, like Bandwidth reports, 404 Pages, and Direct File Downloads. You can also upload these reports to Google Analytics with the GA Upload feature.

 

SETUP INSTRUCTIONS FOR UNIVERSAL ANALYTICS WEBSITES (analytics.js):

If you have any questions about getting this working, please contact our support team - we're happy to help.

We're going to use the task functions in analytics.js to create a request for __ua.gif, which can either be sent to the local web server or to a remote web server. 

  1. Ensure your web server uses the NCSA (apache) or W3C (IIS) logging format.
  2. Add __ua.gif to the root directory of your website(s) - you can copy the file by clicking this link: __ua.gif
  3. From either of the below examples, copy the code between the //START and //END comments and paste it between the "ga('create'[...]" and "ga('send', [...]" lines of the GA tracking code snippet.

Example 1 - Data Sent to Local Server:

// This example shows what your GA code will look like, once you add the Angelfish section to the default code.
<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-XXXXX-YY', 'auto');
// START local backup of GA data request for Angelfish
ga(function(tracker) {
var originalSendHitTask = tracker.get('sendHitTask');
tracker.set('sendHitTask', function(model) {
var payLoad = model.get('hitPayload');
originalSendHitTask(model);
var gifRequest = new XMLHttpRequest(); // Send __ua.gif to the local server
var gifPath = "/__ua.gif";
gifRequest.open('get', gifPath + '?' + payLoad, true);
gifRequest.send();
});
}); // END local backup of GA data request for Angelfish
ga('send', 'pageview');
</script>

 

Example 2 - Data Sent to Remote Server:

// This example shows what your GA code will look like, once you add the Angelfish section to the default code.
<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-XXXXX-YY', 'auto');
// START remote backup of GA data request for Angelfish
ga(function(tracker) {
var originalSendHitTask = tracker.get('sendHitTask');
tracker.set('sendHitTask', function(model) {
var payLoad = model.get('hitPayload');
originalSendHitTask(model);
var gifRequest = new XMLHttpRequest(); // Send __ua.gif to a remote server
var gifPath = "https://www.your-domain.com/__ua.gif";
gifRequest.open('GET', gifPath + '?' + payLoad, false);
gifRequest.send();
});
}); // END remote backup of GA data request for Angelfish
ga('send', 'pageview');
</script>

 

Notes:

  • During processing, Angelfish looks for a file called __ua.gif (i.e. don't change the name!)
  • If using a remote server, edit the value of the "var gifPath" variable with the correct domain or IP address.
  • if using a remote server, we recommend using https as the protocol. But if your site doesn't use SSL, http is fine.

 

SETUP INSTRUCTIONS FOR TRADITIONAL WEBSITES (ga.js):

If you have questions about setup, please contact our support team - we're happy to help.

  1. Add the cookie field to your web server's log format. (IIS Instructions) - (Apache Instructions)
  2. Add __utm.gif to the root directory of your website(s) - you can copy the file by clicking this link:__utm.gif
  3. Reference the _setLocalRemoteServerMode method in the your existing ga.js code snippet.

Sample Code: (use your own UA number, not XXXXX-X)

<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXX-X']);
_gaq.push(['_setLocalRemoteServerMode']);
_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>
 
Topic is closed for comments