I need access to the URL parameters in Shopify when a customer visits my shop.
For example, the customer calls up my shop with www.myshop.com/id=1
, I am interested in the ID.
This ID should then be added to the Shopify database after the purchase has been made.
Later I would like to read out the data in an external project and be able to determine exactly which ID generated how much sales in which period.
Can someone give me a hint how / where to start?
2
Answers
A possible solution would be to read the url parameters from the Order-Webhook under the
referring_site
-Element. It usually looks like this:"referring_site": "https://{shop}.myshopify.com/products/testprodukt-1"
But the problem is that the parameters disappear when the customer changes the page. So it is not shown on the
referring_site
-Element of the webhook.So my plan looks like this:
Insert a Shopify-Scripttag:
dummy.js:
To the code above:
This will make the
referring_site
look like this in the order webhook:"referring_site": https://{shop}.myshopify.com/products/testprodukt-1/?myparam=1
Now you can do what you want with the parameter in the backend, I hope I could help or provide inspiration.
There is a field called
landing_site
on the Shopify order object you can access via the api. That should give you the data you’re after.You can also track
UTM
codes in Shopify’s built in reporting, so you may be able to leverage that without the need for an additional service.