Analytics
2.3K members online now
2.3K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

PayPal tracking without extracting _ga cookie contents

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi guys, I'm trying to track PayPal in ecommerce Analytics by sending users back to a site where the _ga cookie is already set and tracked. Does this approach make sense? I have multiple domains and a wish to use only one PayPal IPN script. Also, I hope to avoid extracting and setting the _ga cookie.

 
My company owns several domains, each with its own webshop. Let's call them www.aaaa.x where x can be .no, .se, .com and severals others. It also owns another domain (let's call it www.bbbb.com) which has very little practical use. The only thing it does is point visitors to the updated www.aaaa.com page.
 
When customers order a product on one of the aaaa.x sites, the Analytics cookie there is set. (Unless the user has opted out.) The value of x is passed rather benignly to PayPal in the products's item_number field. (PayPal's custom field no longer works for Buy Now buttons.) Passing the _ga cookie in this field is weird and possibly against Google regulations.
 
As soon as payment is completed in PayPal, an IPN script (php code with curl) residing on bbbb.com is called by PayPal. It extracts the value of x. So far, so good. This is tested and works well.
 
My idea is to have the script on bbbb.com call a script on aaaa.x (with the correct value for x extracted from the item_number field) which informs ecommerce Analytics about the purchase. That way, the _ga cookie set on aaaa.x will tell Analytics that the loop all the way from AdWords has been closed.
 
I assume I will have to add bbbb.com to the Referral Exclusion List for all the Analytics properties. 
 
Does this approach make sense to you? It shouldn't be too hard to code up, but verifying it across multiple platforms and browsers may be very time consuming. So if this principle is OK, I'll put it together and share the code.
 
 
 
Best regards, 
 
Borge
1 Expert replyverified_user

Re: PayPal tracking without extracting _ga cookie contents

Top Contributor
# 2
Top Contributor
Hi Borge,

If you are tracking all domains under the same property you need to set up cross domain tracking to track the users across the domains:

https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain?hl=en
https://developers.google.com/analytics/devguides/collection/analyticsjs/linker

Let me know if this helps.

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: PayPal tracking without extracting _ga cookie contents

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Thank you for the suggestion. This would help if I wanted to track traffic between aaaa.no and aaaa.se. (Which is probably something I want at some stage.) At the moment, I have multiple Analytics properties, one for each aaaa.x domain. Currently, I have set up ga('create', 'UA-yyyy-5', 'auto', {'allowLinker': true}); ga('linker:autoLink', ['aaaa.co.uk', 'aaaa.dk', 'aaaa.no', 'aaaa.de', 'aaaa.com'] );

What I'm trying to do here has to do with sending my users through a 3rd party site. I wish to record a purchase by routing the user through:
aaaa.no to paypal.com (Buy Now on aaaa.no embeds "x=no" to PayPal "item_number")
paypal.com to bbbb.com (one shared PayPal account and IPN script, extract x=no)
bbbb.com to aaaa.no (IPN script calls script on aaaa.no)
aaaa.no to Analytics (register the purchase)
This whole shebang has the Analytics cookie stored for aaaa.no the whole time, and neither Buy Now nor any of my scripts relates to its value.

Something rather similar works today when PayPal sends users back to my "Thank you" page. But 10-15% of them close the browser tab before that happens, and I loose out on valuable data. My present "Thank You" page, "aaaa.no/thanks.php?utm_nooveride=1" triggers a goal. Lately, adding PayPal to the Analytics Referral Exclusion List removed the need for utm_nooverride. I was thinking about a similar mechanism triggered by an IPN script and not a "Thank you" page.


Thanks,
Borge

Re: PayPal tracking without extracting _ga cookie contents

Top Contributor
# 4
Top Contributor
Hi Borge,

The _ga cookie contains the client ID, you can use it to associate the user with the purchase. You can pass this value to PayPal using the custom data field. Then in the IPN script you can use the measurement protocol to send the transaction data to GA. Let me know if you have questions.

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: PayPal tracking without extracting _ga cookie contents

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
Hi Arnold,

The custom data field is no longer available for "Buy Now" style buttons, only "Add to Cart". See https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitesta...

I have a working IPN script which extracts _ga and sends it along with metadata for "Buy Now". But the implementation is not pretty. The numeric value of _ga is visible to the user, and it show up in my PayPal seller's receipt.

With multiple domains I can't use the same IPN script, unless I switch to cross domain tracking. That's why I wanted to explore the 2-stage process where an initial script extracted the top level domain (much kinder metadata than _ga content to pass through PayPal), and used that to pass the data on to a script, on the same domain as the original purchase, for Analytics submission.



Børge

Re: PayPal tracking without extracting _ga cookie contents

Top Contributor
# 6
Top Contributor
Hi Borge,

Back to your first post, is bbbb.com already added to the referral exclusion lists? What referrer is associated with the purchases in GA? If the user starts on aaaa.x and it's redirected back to that site after the purchase to fire the transaction code then they should still have the correct source data (if no new session is triggered when they arrive from bbbb.com).

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: PayPal tracking without extracting _ga cookie contents

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭
Yes, that is my idea!
I'll put together some test code and see if I can use real time tracking in Analytics. Hopefully I can get things up and running without creating too many bogus transactions.

Thanks,
Børge

Re: PayPal tracking without extracting _ga cookie contents

Top Contributor
# 8
Top Contributor
Hi Borge,

Let me know how you get on. It should work that way.

Arnold Majlath, Google Analytics Top Contributor
Was my response helpful? If yes, please accept it as solution.
Circle Me On Google+ | Visit me @ Redfly Digital

Re: PayPal tracking without extracting _ga cookie contents

Visitor ✭ ✭ ✭
# 9
Visitor ✭ ✭ ✭
Hi Arnold,

I have had a lot of success with this path but I'm not at the finish line yet. My bbbb.com/ipntest.php script is the only IPN script called by Facebook. It picks up PayPal information from sales done through all the different aaaa.x sites. And it uses curl to call the correct aaaa.x/ec_push.php insertion script. This script loads analytics.js. The data looks good throughout.

I just don't see any aaaa.com/ec_push.php traffic in Analytics Real-Time when it is called through the curl code in bbbb.com/ipntest.php. (For the test case I've selected aaaa.com and also selected the aaaa.com property in Analytics.) Now, bbbb.com was until recently on the Referral Exclusion List for all the aaaa.x properties. I don't see aaaa.com/ec_push.php in Analytics Real-time, both with actual PayPal IPN data through bbbb.com/ipntest.php and when I use the same curl code in a test script bbbb.com/1.php.

However, I see Analytics Real-Time aaaa.com/ec_push.php traffic when I request that file directly in a browser. The file holds no proper html, only scripts.

So either Analytics interprets things differently when called from curl or from a browser, or the Ref Exc that was on bbbb.com is still somehow active.

I appreciate any ideas you have as to why this is happening. And I sure do appreciate your ideas if this doesn't seem like the right path.

It's getting late here now. Soon I'll try it again, and I'll see of I can try it from a domain which was never on aaaa.com's Ref Exc list.

I'd prefer Real-Time views to work before I move on to push actual ecommerce data. I have no idea how long the lag will be there.

My curl code does:
$cSession = curl_init();
curl_setopt($cSession,CURLOPT_URL, $__inserter_url);
curl_setopt($cSession,CURLOPT_RETURNTRANSFER,true);
curl_setopt($cSession,CURLOPT_HEADER, false);
$result=curl_exec($cSession);
curl_close($cSession);

where $__inserter_url = "http://aaaa.com/ec_push.php?__value=4...". The parameter passing and URL encoding look quite solid.


Thanks,
Borge