Fredrik
Fredrik

Reputation: 764

Cross-domain conversion tracking - Custom vs GA?

Say I'm starting a site, refer.com, where I post items on an 'affiliation' basis. When users click on my links, they're directed to the site shop.com. If the user I redirect to shop.com makes a purchase, I need that conversion tracked.

I see two possibilities:

  1. Creating a custom tracking library (probably JavaScript) where I request URLs from refer.com to transfer information from shop.com. I guess PHP would work too, but reduces compatibility with clients.
  2. I use Google Analytics cross-domain tracking to do this. I don't want the refer.com GA account to interfere with the shop.com GA account, but as I understand it you can use several accounts on the same page, giving them different identifiers.

I feel like I'm stuck with a narrow set of possibilities. Do I do both? Neither? I need it to be as easy to implement as possible for the client, while also providing relatively bullet proof tracking. What's the standard today? Affiliation services are everywhere, and this type of cross-domain tracking has to be a very used technique. Is there another preferred method of achieving this that I'm not aware of?

This question might seem highly theoretical. While that may be true, answers with code are highly appreciated too.

Upvotes: 0

Views: 294

Answers (2)

Machavity
Machavity

Reputation: 31654

I have a way for this to work but it requires both your domains to have the Universal Analytics code installed. This will not work with the older GA code

https://support.google.com/analytics/answer/1032400?hl=en

You can install multiple instances of the Google Analytics tracking code on your web pages to send data to multiple properties in your account.

You can, for example, install multiple instances of the Universal Analytics tracking code (analytics.js) on your web pages but only one instance of the Classic Analytics code (ga.js).

So (provided they have your GA code installed) when you refer to shop.com what you should do is this

  1. Parse your GA cookie. You can get to it by $_COOKIE['_ga']. The cookie holds a string that has four parts, broken up by periods. (i.e. GA1.3.367110421.1357220305). You want those last 2 numbers (in this example 367110421.1357220305)

  2. Pass the parsed cookie data in your referral to shop.com

  3. shop.com should store the parsed cookie in its session

  4. Last but not least, when shop.com has your referral data it should load your GA code and set your sessions up like this

    ga('create', 'UA-YOUR-GA-CODE', {'cookieDomain': 'shop.com', 'clientId': 'USERS-PARSED-SESSION'});
    

What this does is it passes your GA session to their domain. At this point, GA will keep their session going so you can track what happens on shop.com. Any conversion data they pass to their GA code should be passed to your GA as well.

Is it bulletproof? No. You have to trust shop.com to properly retain and show your referrred GA session ID. But I have to use this methodology to keep my sessions between my primary sites and the centralized checkout we use and it preserves my Adwords conversions, etc.

Upvotes: 4

James
James

Reputation: 923

I feel like if you're looking for ease of use for the client, Google Analytics is a pretty solid option. It is a widely used tool, with lots of documentation and active forums for feedback. Also, from my research on the topicit seems that they've got this type of behaviour in mind already.

An alternate that comes to mind is that, when redirected from site A to site B, they should be forced to authenticate on site B. You could then setup an authentication form that is unique to this referral from site A, and will be filtered into your database separately from regular authentications on site B.

Upvotes: 0

Related Questions