Category Archives: Uncategorized

Console Debugging GA

Below is some code that can be used to help provide some insight into how to test a GA filter real time with the chrome developer console. This was the example code provided by Stephen Hamel in response to a question I posted in the Google Analytics Google+ Community. The goal of this code was to extract the pageID and pass it as the pagename alongside the page title.

var url = document.URL;
var B = ["",document.title];
var A=url.match(/(.+)pageid=([^&#]+)(.*)/);
console.info(A[1]+"pagename="+B[1]+A[3]);

Extract Previous Page Path from Referrer

The following can be used as a custom javascript macro to extract the last piece of the URL path from the referrer. I will typically use something like this code for form submission thank you pages to identify the previous page page and pass it to a label for GA event tracking.

function(){
var referrerPath= document.referrer.split('/');
var endPath = referrerPath[referrerPath.length-2];
if (document.referrer.split('/')[2]!=document.location.hostname)
  {
  return 'external';
  }
else if (referrerPath.length<=4)
  {
  return '/';
  }
else
{
return endPath;
}
}

Welcome

As an agency analyst I get to face a large number of various Analytics requests. The types of clients I get to work with vary greatly and as such the analysis needs are drastically different. Every week provides new challenges and new opportunists to solve these challenges.  Typically from a technology perspective I am using Google Analytics and Google Tag Manager. As such, the focus of this blog, at least to start with, will be how I used these two technologies to solve analytics challenges.  Most of the content will be specific implementation focused around challenges I faced and how I solved them. Occasionally I will re-visit the content with analysis done using the implementations in place.

If there are specific challenges you are facing that you would like help solving using GA and GTM please reach out to me via comments and let me know, perhaps I can help solve the challenge and write a post about it.