In this article, we show you how to customize email templates so that customers receive the matching tracking link with their 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 down.
Add tracking links
First, add the respective tracking URL in your shipping methods under Settings → Shipping. Use %s as the placeholder for the actual tracking code.
Here you will find an overview of the URLs per carrier:
Carrier | Tracking link with placeholder |
Deutsche Post | |
DHL | |
DHL Express | |
DPD | |
GLS | |
Austrian Post | |
Swiss Post | |
UPS | |
DSV (*) | If you want to add a tracking link for DSV, please note the information on this further down. |
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 Enter delivery state: Shipped. Click Edit.
Now scroll to the Mail text section and enter the following code in both the Text and HTML fields at the position where the tracking link should appear. When you create a shipping label, the generated tracking code is automatically saved in the order details under Details → Shipping → Tracking code(s). This 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 your flows
If you add another carrier and use custom shipping flows, check whether the carrier needs to be added there.
Notification by the carrier
In addition to your own shipping confirmation, the carrier can also inform your customer about the shipment. To do so, the carrier needs the customer's email address.
In the shipping method, in the Privacy configuration section, set the transmission of the email address to the carrier to Always. To learn how the privacy configuration works, see How do I configure the shipping methods so that the correct carrier products are selected automatically?
Note: Pickware only transmits the email address for labels that you created via the Pickware tab Shipping labels on the order. If you create labels with a plugin from another provider, for example a different UPS plugin, this setting does not apply.
If you create a label manually in the carrier's portal, for example in the DHL business customer portal, enter the tracking code on the order before you mark the order as shipped. Only then will the tracking code appear in the shipping confirmation.
Special case: Multiple carriers but only one shipping method
Use this method if you only offer one shipping method at checkout (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:
Carrier | Tracking link with placeholder |
Deutsche Post | |
DHL | |
DHL Express | |
DPD | |
GLS | |
Austrian Post | |
Swiss Post | |
UPS | |
DSV (*) | If you want to add a tracking link for DSV, please note the information on this further down. |
In our example, we ship with either DHL or DPD. The email then decides which link to output based on the length of the stored tracking code. 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 Enter delivery state: 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 code is not taken 1:1 into the tracking URL but is converted into an ID via an API. Alternatively, you could therefore link directly to the tracking website (https://mydsv.com/new/tracking/track-shipment), where the tracking code 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 in 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 %}