4

I have recently launched a site for a customer which we would like to track initial visits on URLs like below via Google Analytics, and then track revisits on their respective referral code:

Users visit:

  • domain.com/?ref=code1
  • domain.com/?ref=code2
  • domain.com/?ref=code3

Once they land, we drop a cookie with the ref code and this determines what they see on revisiting the site. They are locked to this ref code unless they go through another affiliate website and come in on a new referral code.

We would like to know which code they came in on, and then know which code is within the respective cookie? That data can then be drilled down into via filters or separate profiles perhaps?

2

You can use UTM query string parameters and assign each of them to a different campaign, which will mark the affiliate. On GA you will be able to analyze the traffic according to this specific campaign and see how many converted.

For example, you can do:

domain.com/?utm_campaign=affiliate1/2/3&utm_source={affiliate_domain}&utm_medium=affiliate-link&ref=code1/2/3

(1/2/3 - a number for each affiliate)

In the default settings of GA, once a user arrives with a new campaign code, he is from that moment assigned to the new campaign.

You will have to ask your affiliate to add these parameters to the target URL, or to do a URL rewrite.

  • Thanks for the answer, I was hoping for an approach that wasn't going via campaign route, so I could segregate them as seperate websites (same domain). Is that possible or is my only option to go down the campaign route? Sorry for the delayed response, I have been flat out today. – Jon Sep 5 '14 at 14:53
  • Is the ref code is unique per referring domain? You can create a view (=profile) on GA that filters traffic according to the referral. But, if the user comes without the ref parameter, she will still be included in that view. – dm-guy Sep 6 '14 at 6:14
1

I second dm-guy that Google Analytics campaigns is the best way to track this.

If your referral code determines the content of the site, you will still have to cookie it yourself: With Universal analytics the campaign information is stored on Google's servers rather than directly in the cookies, so you can't access it to change the page. You will still need to let Google Analytics know about the parameter in the campaign format that it expects.

You have a couple of options for implementing. The first is change the incoming URLs to include the parameters that Google Analytics expects for tracking campaigns. You can use the Google Analytics URL builder to generate something like this:

domain.com/?ref=code1&utm_source=referringsite&utm_medium=affiliate&utm_content=code1&utm_campaign=affiliate-program-2014

If your single code parameter implies all the information that Google analytics needs, then you could set the parameters dynamically with Javascript based on your referral code. Add this to your Google Universal Analytics snippet before the create line when the ref parameter is present in the URL:

ga('set',{
    campaignName:'affiliate-program-2014',
    campaignSource:'referringsite',
    campaignMedium:'affiliate',
    campaignContent:'code1'
});

Documentation:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.