Skip to main content

How do I add a tracking link to my email templates?

Shopify — Add tracking links to your email templates so customers can track their parcels. Store your carriers' URLs in the shipping method settings.

In this article, we show you how to customize email templates in Pickware so that customers receive the right tracking link with the shipping confirmation. We primarily assume that you use a separate shipping method for each carrier. If you only have one shipping method with multiple carriers, you will find a separate section on this further below.

Tracking in Shopify

By default, emails to customers are sent directly from the Shopify Admin and not from Pickware. The tracking code is also passed to Shopify. Shopify then uses the tracking code to automatically recognize the carrier and provides the corresponding link in the email.

This requires that shipping label creation and shipping take place via the same channel – that is, either both via the Pickware Admin or both via the WMS App. If, for example, the label was created in the Pickware Admin but the order was shipped via the WMS App (or vice versa), the tracking code is not transmitted to Shopify.

What does Pickware transmit to Shopify?

Pickware transmits the tracking number and the carrier to the order in Shopify. Pickware does not set the delivery status of a parcel shipment, i.e. whether it is in transit or delivered. Shopify determines this status itself. If Shopify only shows "Tracking added", Pickware has done its part.

Pickware does not transmit tracking numbers that were canceled in Pickware to Shopify.

Orders from TikTok Shop

For orders from TikTok Shop, the carrier mapping must be maintained in the TikTok app. If it is missing, the tracking number may be missing from the fulfillment. In this case, check the carrier allocation in the TikTok app.

Tracking in Pickware

However, if you use Pickware to process, for example, your B2B orders directly in the Pickware Admin, independently of Shopify, follow the steps described below to customize your email template.

Store tracking links

First, store the respective tracking URL in your shipping methods under Settings → Shipping. Use %s as a placeholder for the actual tracking code.

Sendungsverfolgung_Link1.png

Here you will find an overview of the URLs per carrier:

Customize the email template

In the next step, we add the tracking URL to the email template. To do so, go to Settings → Shop → Email templates and look for the template Delivery status entered: Shipped. Click Edit.

Now scroll to the Mail text section and enter the following code in the Text and HTML fields at the position where the tracking link should appear. When you create a shipping label, the generated tracking number is automatically saved in the order details under Detail → Shipping → Tracking code(s). The value of the variable trackingCode is later inserted into the email.

In the Text field:

{% for delivery in order.deliveries %}
{% for trackingCode in delivery.trackingCodes %}
{% set trackingLink = delivery.shippingMethod.trackingUrl|replace({'%s': trackingCode}) %}
Sendung verfolgen ({{ trackingCode }}): {{ trackingLink }}
{% endfor %}
{% endfor %}

In the HTML field:

{% for delivery in order.deliveries %}
{% for trackingCode in delivery.trackingCodes %}
{% set trackingLink = delivery.shippingMethod.trackingUrl|replace({'%s': trackingCode}) %}
<p><a href="{{ trackingLink }}">Sendung verfolgen ({{ trackingCode }})</a></p>
{% endfor %}
{% endfor %}

Check flows

If you add another carrier and use custom shipping flows, check whether it needs to be added there.

Special case: Multiple carriers but only one shipping method

Use this method if you only offer one shipping method (e.g. "Standard shipping") but decide flexibly in the warehouse which carrier you ship with. In this case, the tracking URL is not stored in the shipping method but directly in the email template. The same URLs as above generally apply here as well:

In our example, we ship with either DHL or DPD. In the email, the length of the stored tracking code then determines which link is output. The basic assumption here is that DHL tracking codes are usually longer than 14 characters and DPD tracking codes are shorter.

Go to Settings → Shop → Email templates and open the template Delivery status entered: Shipped. In the Mail text section, enter the following code in each field at the position where the tracking link should appear.

In the Text field:

{% for delivery in order.deliveries %}
{% for trackingCode in delivery.trackingCodes %}
{% if trackingCode|length > 14 %}
{% set trackingLink = 'https://www.dhl.de/de/privatkunden/pakete-empfangen/verfolgen.html?piececode=' ~ trackingCode %}
DHL Sendungsverfolgung: {{ trackingLink }}
{% else %}
{% set trackingLink = 'https://tracking.dpd.de/status/de_DE/parcel/' ~ trackingCode %}
DPD Sendungsverfolgung: {{ trackingLink }}
{% endif %}
{% endfor %}
{% endfor %}

In the HTML field:

{% for delivery in order.deliveries %}
{% for trackingCode in delivery.trackingCodes %}
<p>
{% if trackingCode|length > 14 %}
{% set trackingLink = 'https://www.dhl.de/de/privatkunden/pakete-empfangen/verfolgen.html?piececode=' ~ trackingCode %}
DHL Sendungsverfolgung: <a href="{{ trackingLink }}">{{ trackingCode }}</a>
{% else %}
{% set trackingLink = 'https://tracking.dpd.de/status/de_DE/parcel/' ~ trackingCode %}
DPD Sendungsverfolgung: <a href="{{ trackingLink }}">{{ trackingCode }}</a>
{% endif %}
</p>
{% endfor %}
{% endfor %}

Special case: DSV

DSV has the particularity that the tracking number is not taken 1:1 into the tracking URL but is converted into an ID via an API. As an alternative, you could therefore link directly to the tracking website (https://mydsv.com/new/tracking/track-shipment), where the tracking number then has to be entered manually.

Here is an example in which the variable delivery.shippingMethod.translated.name is first used to check whether the name of the shipping method contains 'DSV'. If so, the link to DSV's general tracking page is inserted; otherwise, the tracking link stored for the respective shipping method is used.

In the Text field:

{% for delivery in order.deliveries %}
{% for trackingCode in delivery.trackingCodes %}
{% if "DSV" in delivery.shippingMethod.translated.name %}
Dein Paket wurde per DSV versendet.
Deine Sendungsnummer lautet: {{ trackingCode }}
Du kannst den Status deiner Sendung hier abrufen:
https://mydsv.com/new/tracking/track-shipment
{% else %}
{% set trackingLink = delivery.shippingMethod.trackingUrl|replace({'%s': trackingCode}) %}
Du kannst den Status deiner Sendung hier abrufen: {{ trackingLink }}
{% endif %}
{% endfor %}
{% endfor %}

In the HTML field:

{% for delivery in order.deliveries %}
{% for trackingCode in delivery.trackingCodes %}
{% if "DSV" in delivery.shippingMethod.translated.name %}
<p>Dein Paket wurde per <strong>DSV</strong> versendet.</p>
<p>Deine Sendungsnummer lautet: <strong>{{ trackingCode }}</strong></p>
<p>Du kannst den Status deiner Sendung hier abrufen:<br>
<a href="https://mydsv.com/new/tracking/track-shipment">DSV Sendungsverfolgung öffnen</a>
</p>
{% else %}
{% set trackingLink = delivery.shippingMethod.trackingUrl|replace({'%s': trackingCode}) %}
<p>Du kannst den Status deiner Sendung hier abrufen: <a href="{{ trackingLink }}">{{ trackingCode }}</a></p>
{% endif %}
{% endfor %}
{% endfor %}
Did this answer your question?