How to read cookies of parent window from an embedded app?

JoesIdeas
Shopify Expert
2265 207 599

I'm trying to read cookie of a user when they install the app, for example:

 

1. Person lands on a specific website page that cookies them

2. They install the app from the Shopify app store

3. Certain actions happen based on if they have the cookie or not

 

Seems cookies aren't accessible, wondering if anyone knows how or has an idea for an alternate flow.


The only idea I have is to find a way to get users to go to the website again to do the cookie check, but that's essentially an extra wasted action.

• Creator of Order Automator (automate tagging, fulfillment, Amazon, notifications + more)
• Shopify developer for 10+ years, store owner for 7 years
• I also make guides like Shopify Automation Tips and How to Deal with Fraud / Chargebacks
Replies 4 (4)

SBD_
Shopify Staff
1829 269 409

Hey @JoesIdeas 

 

I don't think there's a workaround (unless maybe you have their store url during the first step?)

Checking with some other folks - will report back!

Scott | Developer Advocate @ Shopify 

JoesIdeas
Shopify Expert
2265 207 599

Thanks Scott for checking on this.

 

We don't have the store url from the first step, the first step links to the app listing page, attaching cookies, but there are no input forms (trying to make it easiest for the user, direct them to the solution and not make them submit forms).

 

 

• Creator of Order Automator (automate tagging, fulfillment, Amazon, notifications + more)
• Shopify developer for 10+ years, store owner for 7 years
• I also make guides like Shopify Automation Tips and How to Deal with Fraud / Chargebacks
SBD_
Shopify Staff
1829 269 409

Sorry to say they don't have a great solution either:

> yeah that's a tricky one - browsers really don't want you to do that. Maybe setting SameSite=none (MDN) in the cookie might work. That being said, safari is really strict about these (and I think chrome got stricter too recently), so you have to go through ITP to be able to read the cookies from the iframe, which requires a user action (like a click or something)

Scott | Developer Advocate @ Shopify 

JoesIdeas
Shopify Expert
2265 207 599

I wonder if there's a way to transfer the user's Shopify url to Google Analytics when they install the app from the Shopify app store page?

 

Then maybe we could use a url parameter for the referring page, and match that up with the user installing at that same time.

 

Then we could run a separate script that checks Google Analytics via API and compares the url parameter and installed store url with the user, then performs the action (tags them based on the source they came from, to cater specific features, etc).

• Creator of Order Automator (automate tagging, fulfillment, Amazon, notifications + more)
• Shopify developer for 10+ years, store owner for 7 years
• I also make guides like Shopify Automation Tips and How to Deal with Fraud / Chargebacks