This page is part of our wider Shopify guide - if you haven't already, we recommend visiting our Shopify: Getting Started article. If you've upgrade to Checkout Extensibility on your Post Purchase pages, follow this guide: Shopify: checkout.liquid and the Checkout Extensibility Upgrade.
The Referrer tag is used for two purposes:
- To track transactions through Shopify, to ensure friends get rewarded
- To promote the referral scheme to your customers.
Here's an example of what a customer will see when they make a purchase:
What you'll need
For this section you will need:
- Access to your "Checkout" section in Shopify
- Your Mention Me PartnerCode (ask your Onboarding Manager if unsure)
Adding the tags
Open the "Checkout" settings, usually at https://yourshopifysite.myshopify.com/admin/settings/checkout
Scroll down to the "Additional Scripts" section, and add the following code to the Order Status Page additional scripts area, below any existing scripts.
<script>
// Enter your Mention Me partner code here:
var partnerCode = "INSERT_PARTNERCODE";
var urlComponents = [
"https://tag.mention-me.com/api/v2/referreroffer/",
partnerCode
];
// Calculate total number of items ordered
var itemCount = 0;
if (Shopify?.checkout?.line_items) {
for (var i = 0; i < Shopify.checkout.line_items.length; i++) {
itemCount += parseInt(Shopify.checkout.line_items[i].quantity, 10);
}
}
var queryComponents = [
["email", Shopify.checkout.email],
["firstname", Shopify.checkout.billing_address.first_name],
["surname", Shopify.checkout.billing_address.last_name],
["customer_id", Shopify.checkout.customer_id],
["locale", Shopify.locale + "_" + Shopify.checkout.billing_address.country_code],
["segment", Shopify.checkout.billing_address.country_code],
{% comment %}
// Only include order details on first load
{% endcomment %}
{% if first_time_accessed %}
// We use Shopify's internal order identifier
// as there may be cases where the client order id isn't
// available yet
["order_number", Shopify.checkout.order_id],
["order_total", Shopify.checkout.subtotal_price],
["order_currency", Shopify.checkout.presentment_currency],
["order_item_count", itemCount],
["order_discount_amount", Shopify.checkout.discount?.amount],
["coupon_code", Shopify.checkout.discount?.code],
["situation", "postpurchase"],
{% else %}
["situation", "postpurchase-thankyou"],
{% endif %}
];
queryComponents = queryComponents.map((qc) => qc[0] + "=" + encodeURIComponent(qc[1]));
var url = urlComponents.join("") + "?" + queryComponents.join("&");
var script = document.createElement("script");
script.src = url;
document.getElementsByTagName("head")[0].appendChild(script);
</script>
Update the variables
Staying within this page, you will need to make some changes to this code.
PartnerCode
You must update replace INSERT_PARTNERCODE with your own Mention Me PartnerCode. If you don't know it, request your Partner code from your Onboarding Project Manager.
Locales
If you have multiple Locales / Regions that you serve, you may also wish to update the code we have provided.
This is the line:
// Locale
["locale", Shopify.locale + "_" + Shopify.checkout.billing_address.country_code],
By default we will choose a combination of the Locale in Shopify (e.g. English, French, Spanish) and the billing country of the customer (e.g. UK, France, Germany).
You can learn more about setting this via our article on Shopify: Locales.
Optional: Only show the tag on first visit
By default, the Mention Me tags will load every time a user visits the Order Confirmation page.
For most Shopify clients, the Delivery Status page is also the Order Confirmation page, which means that the Mention Me tags will show when someone wants to check the status of their order.
This is an opportunity to raise referral as an option again, but some clients prefer to disable it and only show it once per order. If you'd like to do this, simply wrap the code above with this snippet:
{% if first_time_accessed %} ... snippet from above here
{% endif %}
Useful links
If more information about the customer is required then the variables can be found here: https://help.shopify.com/themes/liquid/objects/customer
If more information about the order is required then the variables can be found here: https://help.shopify.com/themes/liquid/objects/order