Page Level Custom Variables with Urchin

As almost of we all know , Urchin just has one User Level variables support Out of the box, , but what happens if we need to use custom variables under another scope, for example under Page Level Scope?

Well we can use this easy trick with some filters and 2 profiles to achieve this functionality.
We will need to use this tiny script to ensure that we will always have 2 uri segments before the real Uri Path.


<script type=”text/javascript”>
var key = ‘(not-set)’;
var value = ‘(not-set)’;
if (typeof key == “undefined” || typeof value == “undefined” )
var uri = window.location.pathname;
else
var uri = ‘/’ + key + ‘/’ + value + window.location.pathname;
urchinTracker(uri);
</script>

After this we will create 2 filters:

  • One to have the content data without the first 2 uri segments, We will need to use this filter to achieve this

  • Another one that overwrites que content data just with the first 2 segments, so we can view our custom vars data under drilldown report

After this we will create 2 profiles, thyngster.com_orig and thyngster.com_month_cvar for example and we will apply one filter to each them.

We will have then, one profile with the original data, like if we haven’t done any custom urchin code, and another one that will show us the custom var info under Content Drilldown Report within Urchin Interface.

We could had used more than one custom variables and use another filters to split the data, but we will cover this scenario in another post.

I haven’t tried it in a live and real website ( yet ), let me know if it worked for you 🙂

David Vallejo

Google Analytics Consultant and implementer. I have some experience with Google Tag Manager
Follow me: @thyng

Author: David Vallejo

Google Analytics Consultant and implementer. I have some experience with Google Tag Manager Follow me: @thyng

Leave a Reply

Your email address will not be published. Required fields are marked *