Access a community of over 900,000 Shopify Merchants and Partners and engage in meaningful conversations with your peers.
Can someone tell me if I'm just missing somewhere we can retrieve the UTM Campaign, UTM Name, and UTM Source fields that you can download in reports via the API (GraphQL or REST)? I can't seem to find anything about it, but it seems like they should be available somewhere.
Hey @MrPunkin.
You can access this information on a CustomerVisit via the Admin GraphQL API. This can be accessed through Order.CustomerJourney.Moment(CustomerVisit). A query for that would look like this:
query { orders(first:200) { edges { node { customerJourney { moments { ...on CustomerVisit { utmParameters { source campaign content medium term } } } } } } } }
The above makes use of inline fragments, which you can learn more about here if that's unfamiliar to you.
Alex | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Alex,
Thanks for this info. I'll spend some time digging into this today.
To get that data on a specific order, you can query that order directly:
{ order(id: "gid://shopify/Order/5642150741") { id customerJourney { moments { ... on CustomerVisit { utmParameters { source campaign content medium term } } } } } }
Let me know though if I'm misunderstanding your question.
Edit
Looks like you edited your post, I'll put this up regardless.
Alex | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
I did, sorry. I didn't notice that all of this was nested under the orders data at first. This should be what I need, but I'll let you know if it isn't for some reason.
excuse me:
How to get UTM parameters through rest admin API?
I have been searching for rest admin API document for a long time, but I haven't found the appropriate interface to get the UTM parameters associated with the order.
How to get UTM parameters through rest admin API?
Unfortunately I believe this is only available via the GraphQL API, and does not exist within the REST API. I had to implement the GraphQL API for my needs to track the UTM variables from the CustomerJourney object.
I believe Shopify is moving towards exposing some data only via the GraphQL API. I believe this is mostly due to having their core API development moving forward clearly focused on GraphQL. I don't think they can't add it to REST, but rather that they simply wont.