Getting started with AfterShip

Last updated at:

You will learn

Learn how to integrate AfterShip with Klaviyo in order to personalize and target emails based on the shipping events and status of orders tracked by AfterShip. 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.

You can sync data from AfterShip such as:

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

Before you begin

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

Table of contents

  1. Generate an API key in AfterShip
  2. Enable the AfterShip integration in Klaviyo
  3. Update the webhook URL in AfterShip
  4. View synced data
  5. AfterShip metrics
  6. Use AfterShip data in Klaviyo

Generate an API key in AfterShip

First, you'll generate an API key in AfterShip.

  1. Log in to your AfterShip account, locate Settings at the bottom of the left hand navigation, and click on API Keys.
    AfterShip settings page with API keys highlighted in dark gray
  2. Click Generate API Key, and label the API Key for clarity.
  3. Click Generate API Key again to prompt AfterShip to create the newly-named key.
    Description set to Connection with Klaviyo and Generate API Key with purple background
  4. Copy the API key for use in Klaviyo.

Enable the AfterShip integration in Klaviyo

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

  1. In Klaviyo, click your account name in the lower left corner and then select Integrations.
  2. Click All Integrations, then search for AfterShip. Next, click Add Integration.
    All Integrations tab in Klaviyo with AfterShip in searchbar and AfterShip card in results
  3. In the API Key field, paste the AfterShip API key you created, then click Connect to AfterShip.
    AfterShip integration settings page in Klaviyo with API key blurred out
  4. 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.
    Integration settings page in Klaviyo with webhook URL highlighted in blue

Update the webhook URL in AfterShip

  1. From your AfterShip account, navigate to Notifications > Webhooks.
    Notifications dropdown with Webhooks highlighted in gray
  2. Click Add webhook URL.
  3. Paste the webhook URL you copied from your Klaviyo account, and click Save.
    Add webhook URL popup with webhook URL in text box and Save with purple background
  4. 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.
  5. AfterShip will now sync all tracking events over to Klaviyo.

View synced data

To check on your integration:

  1. Click the Analytics dropdown and select Metrics.
  2. 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.
    Metrics tab in Klaviyo filtered by AfterShip with Received Delivery in list
  3. 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 (found under Account Name > Integrations), your historic data sync is complete.
  4. 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

Metrics tab in Klaviyo filtered by AfterShip with a list of metrics including Delivery Exception and Shipped Package

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.

Use AfterShip data in Klaviyo

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. This data can be used to create and trigger flows based on a shipment’s status.

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

Flow in Klaviyo flow builder triggered by Out for Delivery

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.

  1. First, in AfterShip, click on Tracking pages.
    Tracking pages in menu in purple
  2. Select the tracking page you’d like to add to your email template and copy the following from the provided URL:
    Tracking page preview with URL
  3. In Klaviyo, navigate 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.
    AfterShip flows in Klaviyo flow library including Order in Transit
  4. In this example, we’ll add the tracking number to the Order In Transit flow. Click on the Order In Transit flow.
  5. Select the email block and then click Edit.
    Klaviyo flow builder with flow email highlighted titled AfterShip in Transit Email #1
  6. 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 template builder with main text box selected
  7. Select the placeholder text next to Tracking Number and click the link button.
    Text box settings in template builder with Link button selected
  8. 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' }}
    Link info modal with URL in box
  9. Click OK. Then, save your changes to the block by clicking Save.
    Text box settings in template builder with tracking number variable linked
  10. 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.
  11. Once you’re happy with the way your email template looks, click Save & Return to Templates.


You've now integrated AfterShip with Klaviyo and learned how to use your synced data.

Additional resources

Was this article helpful?
256 out of 364 found this helpful