Topics covering webhook creation & management, event handling, Pub/Sub, and Eventbridge, in Shopify apps.
We're trying to find the traffic source for an order placed on a Shopify store, such as Google Ads or Meta Ads. Which is the API/field we can use for this purpose?
We are able to fetch the marketing events from marketing_event API but there are no fields in this API or the orders API that links the 2. Hence, we're unable to attribute an order to a specific marketing source or marketing event.
We are an analytics app that gives unique and actionable insights for Shopify stores
Hi @abhishek_merito 👋
The `CustomerVisit` object has multiple fields for tracking a source/referrer. For example, we can fetch details about the last session before the order was made with the below:
{
order (id : "gid://shopify/Order/123"){
customerJourneySummary {
lastVisit {
source
referrerUrl
utmParameters {
campaign
source
}
}
}
}
}
Hope that helps!
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
Thank you for your reply!
I had a couple of follow up questions -
- Is the above mentioned code the source of the session for the purchase? Checking because it says last visit
- Will the source field in your solution only be from UTM links? If a Store has not added UTM links, will this field still show the source of the order?
Happy to help!
The `CustomerJourneySummary.lastVisit` field reflects the last session before the order is made. The `moments` connection can be used to review all events leading to an order as well:
{
order(id: "gid://shopify/Order/123"){
customerJourneySummary {
moments (first:10){
nodes {
occurredAt
... on CustomerVisit {
source
}
}
}
}
}
}
I'd recommend reviewing this page that describes all fields available on the `CustomerVisit` object, to find one that suits your use-case.
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
It is useful to get first and last visit of a customer for an order.
However, how to get the CustomerVisit information of all the sessions, instead of getting only first and last sessions?
Shopify itself displays just "Returned x times", no way to get the detailed information for this x times of sessions?
Thank you.