Updated 2025
Shopify has been busy shaking things up recently, and if you’re still clinging to the “landing_site” field in the REST Admin API or mourning the loss of the “Additional Scripts” section, it’s time for an upgrade! Our old solution to capture UTM parameters in landing_site is no longer needed because of these changes.
TL;DR – No need to worry about this implementation anymore. You’re already convered and Shopify will capture UTM parameters for you by default.
What Changed?
Here’s the lowdown:
- Farewell, REST API: The landing_site field from the REST Admin API has been replaced by the landingPage property in the GraphQL Admin API. Shopify officially retired REST as of October 1, 2024.
- Bye-Bye, “Additional Scripts”: The beloved (and sometimes clunky) “Additional Scripts” section has been replaced with Custom Pixels for event-based tracking.
- More Granular Attribution Data: Shopify’s new
CustomerJourneySummary
/ CustomerVisit
objects include fields like utmParameters, source, and referrerUrl to give you better insights into your customers’ journeys.
You can find more about adding custom pixels here →
Need help setting up custom pixels? Get in touch with us →
The rest of the article is no longer valid
In Shopify, you can easily add UTM tracking parameters to your product links and capture them in the landing_site field when you receive an order webhook.
Here is a quick way to do so:
- Login to your Shopify store and go to the “Online Store” section.
- Click on “Preferences” and scroll down to the “Google Analytics” section.
- Under “Additional Google Analytics JavaScript”, add the following code:
{% if first_time_accessed %}
ga('set', 'campaignName', '{{ request.params.utm_campaign }}');
ga('set', 'campaignSource', '{{ request.params.utm_source }}');
{% endif %}
This code will capture the UTM parameters from the URL when the customer first accesses your store and set them as custom variables in Google Analytics.
- Save the changes and go to the “Settings” section of your store.
- Click on “Checkout” and scroll down to the “Order processing” section.
- Under “Additional scripts”, add the following code:
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function(event) {
var utm_params = new URLSearchParams(window.location.search);
if (utm_params.has('utm_source') && utm_params.has('utm_campaign')) {
var landing_site_field = document.querySelector("#checkout_shipping_address_landing_site");
if (landing_site_field) {
landing_site_field.value = window.location.href;
}
}
});
</script>
This code will capture the UTM parameters from the URL when the customer places an order and store the URL in the “landing_site” field of the shipping address.
- Save the changes. Grab a coffee.
0 Comments