Retrieving URL parameter from order

Topic summary

Issue: Retrieve a custom URL parameter (subid) from an order via Shopify Admin GraphQL API.

Key facts:

  • Current capability (API version 2023-04): Only non-UTM parameters supported are ref, source, and r.
  • Location in GraphQL: Order.customerJourneySummary.firstVisit.referralCode (and lastVisit) returns the value of ref/source/r from the landing URL.
  • Custom parameters like subid aren’t exposed via the API.

Clarifications:

  • No existing Shopify Admin API version (checked across versions) supports fetching arbitrary custom URL parameters beyond ref/source/r.
  • UTM parameters (e.g., utm_source, utm_medium) are separate; custom params like subid aren’t included.

Suggested workaround:

  • Capture subid from the landing URL on the storefront and store it as a metafield on the Order (metafields = custom data fields).
  • Then retrieve the subid via the order’s metafields in API responses.

Status and next steps:

  • Feature not supported; workaround requires custom implementation.
  • Shopify support has forwarded feedback to the product team. Discussion effectively answered but feature request remains open.

Note: An image was shared, but the core answer doesn’t depend on it.

Summarized with AI on January 25. AI used: gpt-5.

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.

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-referralcode

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

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:

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