Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Retrieving URL parameter from order

Retrieving URL parameter from order

miwelo
Tourist
10 0 7

Hello,

 

There is a platform sending me traffic very much like an affiliate network. Their users have a "subid" parameter in the URL that looks like this: "http://mysite.com?subid=12345"

 

Then I make an API call to fetch the order details but I don't get to find any field with this parameter. I saw some people fetching UTM parameters via GraphAPI calls but I think that's limited to source, medium and etc, not custom parameters like the one I need.

 

If somebody has the answer that'd be great.

Replies 3 (3)

ShopifyDevSup
Shopify Staff
1453 238 518

Hi @miwelo,

 

Thanks for your post. As of Admin API version 2023-04 the only non-UTM url parameters available via API are 'ref', 'source', and 'r' which are available on the Order object in GraphQL under Order.customerJourneySummary.firstVisit.referralCode (similarly with lastVisit).

 

Here's a link to the documentation about that: 

https://shopify.dev/docs/api/admin-graphql/2023-04/objects/CustomerVisit#field-customervisit-referra...

 

referralCode: Marketing referral code from the link that the customer clicked to visit the store. Supports the following URL attributes: ref, source, or r. For example, if the URL is myshopifystore.com/products/slide?ref=j2tj1tn2, then this value is j2tj1tn2.

 

Hope you have a great day,
Jon551

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

miwelo
Tourist
10 0 7

Hi, thank you for your assistance.

 

Do you mean that I will not be able to fetch a paramenter named "subid" and I can only fetch a parameter named "ref", "source", and "r"?

 

Do you know if I could achieve this with another API version of Shopify?

 

At the moment I'm getting this result:

 

input-output.JPG

ShopifyDevSup
Shopify Staff
1453 238 518

Hi @miwelo,


That's correct, the current API version (2023-04) only supports fetching URL parameters named "ref", "source", and "r", custom parameters like "subid" are not supported. Checking the documentation for all currently supported API versions, currently none support fetching custom parameters.
 

One possible workaround to explore, would be storing the "subid" value to a metafield. This would allow you to fetch your custom data as metafield value along with the order details. You would need to build an implementation that captures the "subid" value from the URL and then write it to a metafield value on the order object. More info on metafields can be found here: https://shopify.dev/docs/apps/custom-data/metafields


That workaround may require additional development work on your end, so I've opted to advocate for the use case that you are looking to achieve and pass on some feedback to our product team for future consideration.
 

Hope this helps clarify - Cheers! 
@awwdam | Shopify Developer Support

 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog