FROM CACHE - en_header

Way to access a 1st party cookie set on my store from the checkout page?

Allan_Gourdie
Shopify Partner
20 0 1

I'm trying to integrate a new affiliate network tracking solution with Shopify.

I understand I can pass in URL parameters like ?ref=new_affiliate_partner and access them via {{landing_site_ref}} on the Thank You page https://checkout.shopify.com/orders/nnn/nnnnnnn

But, I don't want to pass additional URL parameters as my affiliate solution appends a specific # value to the end of my links.

I've got some working javascript to set a cookie when I land on my test store with attributes from one of these # fragments, and I'm now trying to figure out how to then access the value of that cookie from the Thank You page.

I've read some forum posts that suggest using CORS but when I tested with the bogus gateway, it didn't add any additional CORS headers to allow me to call back to my own store to retrieve this value.

If this approach isn't going to ever work with the current Shopify architecture, is there an alternative approach via an App or the API that someone can recommend?

Any help much appreciated,

Allan

Replies 5 (5)
HunkyBill
Shopify Expert
4793 56 562

First off... affiliate parameters are already saved by Shopify and are part of the order. You get the landing page, and any affiliate codes in the order itself. Dealing with cookies and checkout will never be of much use to use since you cannot do anything with checkout. You can inject script code in the Thank You page, and there you do have access to the order in Liquid, so you can get your codes from the order there. 

Has nothing to do with CORS since you're dealing 100% with Shopify here and not an external App you control, where cross-domain Ajax might come in handy.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
Allan_Gourdie
Shopify Partner
20 0 1

Hi Bill.  When you say "affiliate parameters are already saved by Shopify and are part of the order", are you talking about the landing_site_ref feature where you do something ?ref=... ?  If not could you give an example of an affiliate parameter that is available as part of the order.

I understand lots of affiliate systems use heavily encoded link tagging and 3rd party cookies.  My system tries to use only first party cookies to ensure this will work on mobiles and tablets where the majority of iOS6 users now block 3rd party cookies by default.

I thought CORS might come in handy and the Thank You page is on https://checkout.shopify.com but my shop's 1st party cookie is sitting on myshop.com

If you can explain how I can pass affiliate parameters into my order without using the landing_site_ref feature, that would be awesome.

HunkyBill
Shopify Expert
4793 56 562

When you capture the Affiliate code, scraping it out of the URL using Javascript in your theme, you can save it as a cart attribute. Those get passed to the order, and are available for the lifecycle of an order... start to finish, provided a cart exists. And those are not a given until someone puts something in the cart, so you can just save the affiliate code as a cookie till the cart exists and then once it exists, persist the affiliate code as a cart attribute. 

You're on your own here, as you can make up dozens of ways of playing with Shopify and this kind of processing. Experiements will lead you to the best choice for you.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
Allan_Gourdie
Shopify Partner
20 0 1

Fantastic!  That sounds like a great plan of action.  Thanks

Allan_Gourdie
Shopify Partner
20 0 1

Got it working perfectly now using a custom cart attribute.  Thanks for all your help.