Google Analytics goal conversion funnels across subdomains with regular expressions

Bit of a mouthful I know – but I spent hours trying to find this on the net, with little luck.  So I thought I would write a comprehensive article on how to solve this problem.  This article explains the process of setting up funnels for multiple conversion paths over different subdomains using regular expressions. It assumes you are already using funnels and are familiar with the basics of Google Analytics. If you are looking for a basic guide to setting up funnels, try here, if you are already familiar with basic funnel setups then read on!

What are funnels?

Funnels are a great way to visualize your visitors’ paths through your site, with the aim of completing a particular goal. Using funnels can help you identify usability problems in your site that need to be addressed in order to increase click through rates and ultimately conversion rates.

How to create a funnel across different subdomains

Example

mypointyhat.com wants to track visitors who land on a forum post at forums.mypointyhat.com and end up buying a pointy hat from www.mypointyhat.com/shop they then want to look at the funnel visualization for this particular behaviour.

Setting up cross subdomain tracking correctly

Before creating a funnel across different subdomains you need to ensure that you have setup the tracking on the site correctly. Firstly you need to check that the Google Analytics script is the same code on each sub domain with addition of a piece of code:

pageTracker._setDomainName(“.mypointhat.com”); (for example)

Once you have setup the tracking you need to setup an advanced filter, otherwise forums.mypointyhat.com/index.php and www.mypointyhat.com/index.php would both be treated as /index.php. To do this you setup an advanced filter and use the data shown in the following image:

Advanced Filter for Sub Domains

Advanced Filter for Sub Domains

Once these two things are done your pages will appear with their subdomain attached:

e.g. forums.mypointyhat.com/index.php and www.mypointhat.com/index.php instead of /index.php

If you need further instructions Google talks you through it here

How to create a funnel that works across subdomains using regular expressions

I’m guessing you have a funnel in mind, but for this one we are going to use the example I mentioned above. So essentially we want to track the funnel from forums.mypointyhat.com/thread/post-title through to www.mypointhat.com/shop/confirmation.php.

Regular Expression Matching

If you are not familiar with regular expressions, I suggest you do a Google search and do some background reading – once you understand regular expressions it gives you a whole new World of options to consider when trying to solve complex problems and arduous tasks.

The first point I will make is that in regular expressions a . (period) represents a character, therefore to get a . (period) to actually represent a . (period) you have to escape it before hand (so the program understands that it is a literal reference) the syntax for this is a backslash:

e.g. .

Also please note, I haven’t tested my regular expressions in the example below, so they may not work – so no copying!!!

Bearing those points in mind our steps will look like the following:

The first part to setting up the goal involves activating the goal, setting the match type as regular expression, choosing the goal and the goal name (see image below for an example)

goal-settings-a

Step 1: forums.mypointyhat.com/thread/[A-Za-z-]+ Forum Thread (Required Step should be checked)
Step 2: www.mypointyhat.com/shop/index.php Homepage
Step 3: www.mypointyhat.com/shop/products/[A-Za-z-]+.php Product Page
Step 4: www.mypointyhat.com/shop/basket.php Basket Page
Step 5: www.mypointyhat.com/shop/checkout.php Checkout Page
Step 6: www.mypointyhat.com/shop/payment.php Payment Page
Goal: www.mypointyhat.com/shop/confirmation.php Confirmation Page

Don’t forget to escape your periods!!! See the example below for a better illustration of where these URL’s go:

goal-settings-b

Now give it a day, if it doesn’t work you can check your funnel analysis and see where the problem is occuring. If you are still having problems check Google – if you STILL have problems – ask me on Twitter and I’ll do my best to help you 🙂

I must also give credit to Mr Mcskelly, who setup the cross subdomain tracking before I had to tackle the funnels on one of our client’s sites.


We'd love to hear from you!

If you think Bronco has the skills to take your business forward then what are you waiting for?

Get in Touch Today!

Discussion

  • Amanda

    Thank you! I so needed this!

  • David W

    Thats ok Amanda, let me know if you need help with anything 🙂

  • duncan bloor

    If you’ve gone through all of this and still no joy then the Google analytics help forum is a useful source of expertise.

    @DaveN, have you taken the Google analytics individual qualification yet? It’s tricky but I’ve been using GA for a couple of years now and it taught me loads that I didn’t know – really useful.

  • Arturo

    So how would the Funnels look for the Steps and how would the goal URL look? Just want to be sure, thanks. We don’t use regular expression matching. We set up everything else and are setting up the Goal now. Thanks again.

  • David W

    It depends. If you are using subdomains then you would use the full URL (without http):

    e.g. http://www.example.com/goal.html

    But if you are using it on the same domain then you would use the relative address:

    e.g. /goal.html

  • Arturo

    Ok, so if our goal is on one subdomain: /subdomain.main.com/index.php?a=new_account
    and our funnels include pages on the main site (not same as subdomain):
    /index.html
    /about.html
    /another.html

    then this is it how it should appear, as it works fine for us it seems. But what if another funnel includes another page on the subdomain? would we type in:
    /subdomain.main.com/newpage.html

    thanks.

  • David W

    You should probably use the full domain name so instead of what you put, I would use:

    Goal: subdomain.main.com/index.php?a=new_account

    http://www.main.com/index.html
    http://www.main.com/about.html
    http://www.main.com/another.html

    But I think it treats both the same (I just prefer it that way as it removes any chances of confusion).

    If another page is included you would include:

    subdomain.main.com/newpage.html

    The fact you are putting a / before your subdomain URL’s leads me to believe you may not have added the domain tag:

    pageTracker._setDomainName(”.main.com”);

    to the Google Analytics script – am I correct? Just I have done this before and all the subdomains appear with a backslash before them…

  • erotiske artikler

    Thanks for explaining “funnel” the easy and more comprehensive way. But is the actual task of doing it as easy as your explanation?

  • Advice for women

    Thank you for making it clear. I’ve been trying my hand on Google Analytics but has grown frustrated over time. But does regular expression matching make a world of difference?

  • harvey

    Awesome. It looks like this is working. Thank you!

    I have only included the sub directory in where appropriate and used the full subdomain where neccessary.

    Thanks David

  • James Winfield

    Hi David,

    I think I have a problem on my funnel – on stage 3 it keeps showing some progressing to stage 4 as normal, but also some “exiting” to stage 4. Why is it showing some of these as leaving when the URL they are going to is the next stage in my funnel?

    stage 3 is /shop/checkout
    stage4 is /shop/checkout/payment-details

    Can you advise on this?

  • David W

    Hey James,

    The only thing I can think of right now is that perhaps people are going to /shop/checkout/payment-details/ instead of /shop/checkout/payment-detail and GA is treating them as separate pages. But really that is clutching at straws.

    It’s hard to tell when you don’t know the URL, what is the website?

  • verSuS

    Hi,
    I have goal on subdomain, and all visitors came thru main domain. Unfortunetly when they complite goal referer is from main domain. How to track true referer, which visitors come to my site?

  • Moot

    Mate, thanks for the info it was really helpful. But could you please make the screenshots smaller? :p (It’s hard to read as it is at the moment)

  • Derek

    Hello,

    We have an AdWords and Analytics account setup. Both of these accounts are successfully linked together. However, we are having problems utilizing the “Goals” feature in Analytics.

    After a user clicks on our ad within Google, they are taken to our main site. (www.mobilestorm.com). We would like to be able to track when they reach our sign up page (http://app.mobilestorm.com/signup/step1) after navigating our website. How do we setup the goals when it says that it should not contain a sub-domain?

    Is there anyway to do this if our Goal URL is a sub-domain of our main URL?

    Please let me know.

    Thanks!

  • David W

    Yes there is, you need to set it up so you can track across sub domains first though. Then when you setup the goals and the funnel you must include the entire address – to show which sub domain.

  • noname

    number of visitors to my page are constantly changing sometime i get about 100 and sometimes only 10 visitors.

  • Shane

    Brilliant guide, thanks for the help. Hopefully my Goal Funnels should work by changing it to the regex values…

Get in touch