How to Integrate with AfterShip

Last updated at:


Klaviyo’s native integration with AfterShip allows you to automatically track shipments for your ecommerce store. When enabled, this integration will send AfterShip tracking information back to Klaviyo via a webhook, so you can incorporate shipping data into automated flows in near real-time.

AfterShip's integration with Klaviyo is only available for AfterShip customers with paid plans.

You can sync data from AfterShip such as:

  • Shipment tracking numbers and order IDs
  • When a shipment is marked as shipped or delivered

This article will walk you through integrating AfterShip with Klaviyo. After completing the steps in this guide, you'll be able to personalize and target emails based on the shipping events and status of orders tracked by AfterShip.

Enable Klaviyo's AfterShip Integration

First, generate an API key in AfterShip. Log into your AfterShip account, locate Settings at the bottom of the left hand navigation, and click on API Keys.

Navigate to AfterShip's settings in the lower left hand corner of the page and then click on API Keys on the right hand side of the webpage

Click Generate API Key, and label the API Key for clarity. Then click Generate API Key again to prompt AfterShip to create the newly-named key.

Describing a new API key as Connection with Klaviyo, with a cancel and a Generate API key in the bottom right hand corner of the popup box

Copy the API key generated by AfterShip and head over to Klaviyo.

Treat private API keys like passwords kept in a safe place and never exposed to the public.

Navigate to the Integrations tab, search for AfterShip on the All Integrations tab, and click Add Integration.

Filtering for AfterShip integration in Klaviyo, showing only the AfterShip integration with an Add Integration button on the right

In the API Key field, paste the AfterShip API key you created, then click Connect to AfterShip.

Blurred out API key pasted into Klaviyo integration with a button below named Connect to Aftership to complete the integration

After you select Connect to AfterShip, your page will reload. In the Setting Up the AfterShip Webhook section, copy the provided webhook URL. You will need to paste this URL into AfterShip in the next step. Without the webhook set up, AfterShip cannot sync data to Klaviyo.

Webhook URL provided from Klaviyo to copy and paste into AfterShip, with identifying public API key blurred out

Head back over to AfterShip to finish setting up the webhook.

Update the AfterShip Webhook URL

From your AfterShip account, navigate to Notifications > Webhooks.

AfterShip Notifications menu, selecting Webhooks section to add Klaviyo webhook URL

Click Add webhook URL.

In webhooks menu, click add webhook URL on left hand side of the page

Paste the webhook URL you copied from your Klaviyo account, and click Save.

Adding Klaviyo webhook URL to popup box with cancel and save buttons in the bottom right hand corner

In the Events section, make sure the All events checkbox is enabled. This will ensure that all events will be sent to Klaviyo from AfterShip.

Highlighted section of AfterShip site to verify the All Events radio button is selected

AfterShip will now sync all tracking events over to Klaviyo.

Monitor the Klaviyo Sync

To check on your integration, navigate to Analytics > Metrics. Select one of the AfterShip metrics — for instance, Received Delivery — and click on the Activity Feed icon. You can filter metrics by ‘AfterShip’, and all AfterShip metrics will have an AfterShip icon.

Screenshot from Klaviyo showing filtered metrics searching for first Received Delivery in the textbox and then Aftership in the dropdown, and the Received Delivery metric shown below

If your integration has begun syncing data, you'll start to see Received Delivery events being added to this Activity Feed. When your AfterShip integration has a green bar in your account's Enabled Integrations list, your historic data sync is complete.

If you aren't seeing data, make sure the All events setting is enabled in the Notifications > Webhooks section of your AfterShip account.

AfterShip Metrics

AfterShip syncs the following metrics to Klaviyo:

  • Delivery Exception
  • Failed Delivery Attempt
  • In Transit
  • Out for Delivery
  • Received Delivery
  • Shipped Package

Screenshot of Klaviyo showing all AfterShip metrics, filtering for AfterShip in the dropdown menu

Delivery Exception

This metric is recorded each time a delivery is assigned one of the following statuses: custom hold, undelivered, returned shipment to sender, or any shipping exceptions.

Failed Delivery Attempt

This metric is recorded when a carrier attempted to deliver the package but failed. The carrier will usually leave a notice and will try to deliver again.

In Transit

This metric is recorded when a carrier has either accepted the shipment or picked up a shipment from a shipper. The shipment is on the way to its destination.

Out for Delivery

This metric is recorded when a carrier is about to deliver the shipment or the shipment is ready to pick up.

Received Delivery

This metric is recorded every time a delivery is marked as received inside of AfterShip, and includes information about an order's tracking number and order ID.

With this metric, you can filter product review flows to send only to people who have received a delivery. You can also trigger a flow when a delivery is received, letting customers know when their packages arrive.

Shipped Package

This metric is recorded every time an order is marked as shipped in AfterShip, and includes information about an order's tracking number and order ID.

With this metric, you can trigger flows to send messages confirming that a package has been shipped to a customer and provide them the tracking number to track their shipment.

How to Use the AfterShip Integration

Each of the metrics above are associated with additional data, also known as metadata. For example, the Out For Delivery metric tracks the package’s CurrentStatus, which includes the following possibilities: AttemptFail, Delivered, Exception, InfoReceived InTransit, OutForDelivery.

Creating a trigger flow using the Out For Delivery subcategory of Current Status

This data can be used to create and trigger flows based on a shipment’s status, as shown below.

Out for Delivery Flow

Let your customers know that their order is out for delivery by using AfterShip metrics and metadata, and populate your flow email with dynamic order information.

  • Trigger: People enter this flow when an Out for Delivery event occurs

Screenshot of Klaviyo flow using Out for Delivery, sending an email to customers with customized property placeholder

Notice that the flow email references dynamic customer order data (i.e., {{ event.extra.Title }}); when the message is sent, the dynamic placeholder will be replaced with the customer’s order number.

Add Tracking Information to Emails

You can also use AfterShip data in direct interactions with your customers; for instance, auto filling their tracking information into a shipping notification email.

This method can only be used in flows with the AfterShip trigger Shipped Package.

First, in AfterShip, click on Tracking pages.

AfterShip's page selection menu with Tracking pages highlighted

Select the tracking page you’d like to add to your email template and copy the following from the provided URL:

Default tracking page URL to copy tracking page URL

In Klaviyo, go to Flows. If you have previously set up an AfterShip flow, you can add the following to that flow. Otherwise, click Create Flow and filter by AfterShip.

Klaviyo Flow creator, filtered by lower left checkbox selected for Aftership, showing Order In Transit, Order Out for Delivery, and Recieved Delivery flows

In this example, we’ll add the tracking number to the Order In Transit flow.

Click on the Order In Transit flow. Select the email block and then click Edit.

Klaviyo Order in Transit flow, with the email box in flow selected, to edit the email via the Edit button on the left hand side

Click Edit Content and select the main text box of the email. In this example template, the text box is set up with two columns, so select Column 2.

Klaviyo email editor, with text block selected to edit tracking number placeholder text

Select the placeholder text next to Tracking Number and click the link button.

Klaviyo text box editor, tracking number placeholder text highlighted and cursor hovering over Link button in top edit bar

In the link menu, change the Protocol to https:// and paste your tracking URL, adding the following to the end:

/{{ event.extra|lookup:'Tracking Number' }}

Klaviyo link editor, with protocol selected to https with the tracking page URL and custom placeholder text added to url

Click OK. Then, save your changes to the block by clicking Save.

Klaviyo text editor with link added to custom placeholder text for Tracking Number, with Save button in upper right hand corner highlighted

You can preview your email by clicking the Preview button on the left hand side of the screen. Select an event to preview the email with, and then choose Show directly in Klaviyo to view the email in your browser. Click Preview Now to view the email and verify your link works.

Once you’re happy with the way your email template looks, click Save & Return to Templates.

Additional Resources

Was this article helpful?
251 out of 358 found this helpful