How To Process Google Analytics Data With Angelfish

Google Analytics' Universal 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 self-hosted, secure, on-premises web analytics software. Learn more here:


 

Benefits of using Angelfish with GA


GA BACKUP
Angelfish can maintain a "backup" of your data - useful if you can't access your Google Analytics account.

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 shows information that doesn't exist in Google Analytics, like Visits that block JavaScript-based traacking.

 

Setup Instruction: Universal Analytics (analytics.js)


If you have any questions about getting this working, please openm a support ticket - we're happy to help.

This solution uses 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.

  • Ensure your web server uses the NCSA (apache) or W3C (IIS) logging format.
  • Add __ua.gif to the root directory of your website(s)
  • https://analytics.angelfishstats.com/downloads/__ua.gif
  • For 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 = document.createElement("img"); 
    // Send __ua.gif to the local server
    var gifPath = "/__ua.gif";
    gifRequest.src = gifPath + '?' + payLoad;
  });
});
// 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 document.createElement("img");
    // Send __ua.gif to a remote server
    var gifPath = "https://www.your-domain.com/__ua.gif";
    gifRequest.src = gifPath + '?' + payLoad;
  });
});
// END remote backup of GA data request for Angelfish

ga('send', 'pageview');
</script>

 

NOTES
During processing, Angelfish looks for a file called __ua.gif
If __ua.gif is requested from a remote server, edit the value of the "var gifPath" variable with the correct domain or IP address.

Setup Instructions for Traditional Websites (ga.js)

If you have questions about setup, please open a support ticket - we're happy to help.

NOTES
  • Add the cookie field to your web server's log format. (IIS Instructions) - (Apache Instructions)
  • Add __utm.gif to the root directory of your website(s)
  • https://analytics.angelfishstats.com/downloads/__utm.gif
  • Reference the _setLocalRemoteServerMode method in 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>
Creation date: 5/18/2022 5:08 PM (Angelfish Support)      Updated: 6/10/2022 7:39 AM (Angelfish Support)