Extracting the marketing source for an order placed on a Shopify website

Extracting the marketing source for an order placed on a Shopify website

abhishek_merito
Tourist
4 0 8

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

Replies 5 (5)

ShopifyDevSup
Shopify Staff
1453 238 512

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

abhishek_merito
Tourist
4 0 8

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?

ShopifyDevSup
Shopify Staff
1453 238 512

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

vinh0225
Shopify Partner
128 26 25

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.

Was my response useful?  Click Like to let me know!
Was your query resolved? ✓ Mark it as a Resolved Solution
If you need custom Shopify changes, ️you can hire me.
Contact me at  ✉️ jalicorich@gmail.com.
ranjithnm
Shopify Partner
7 0 3

We are currently using UTM parameters to track orders from marketing links. However, we have encountered some issues where the entire conversion summary section is missing for certain orders, displaying the message "There aren't any conversion details available for this order." Additionally, in some cases, the conversion summary is available, but the UTM parameters are missing, showing the message "No UTM parameters were available for this session." In both scenarios, we have confirmed that the UTM parameters are available as query parameters upon the initial load, and the '_shopify_sa_p' cookie value is not empty and is updated with the UTM parameter value until the checkout is completed.

 

Furthermore, we have observed that if ad blockers are installed in clients' browsers, the UTM parameter update in the conversion summary section is not being reflected.
Do you have any idea about this issue?