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
- Generate an API key in AfterShip
- Enable the AfterShip integration in Klaviyo
- Update the webhook URL in AfterShip
- View synced data
- AfterShip metrics
- Use AfterShip data in Klaviyo
Generate an API key in AfterShip
First, you'll generate an API key in AfterShip.
- Log in to your AfterShip account, locate Settings at the bottom of the left hand navigation, and click on API Keys.
- Click Generate API Key, and label the API Key for clarity.
- Click Generate API Key again to prompt AfterShip to create the newly-named key.
- 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.
- In Klaviyo, click your account name in the lower left corner and then select Integrations.
- Click All Integrations, then search for AfterShip. Next, click Add Integration.
- In the API Key field, paste the AfterShip API key you created, then click Connect to AfterShip.
- 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.
Update the webhook URL in AfterShip
- From your AfterShip account, navigate to Notifications > Webhooks.
- Click Add webhook URL.
- Paste the webhook URL you copied from your Klaviyo account, and click Save.
- 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.
- AfterShip will now sync all tracking events over to Klaviyo.
View synced data
To check on your integration:
- Click the Analytics dropdown and select 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.
- 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.
- 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
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
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.
- Select the tracking page you’d like to add to your email template and copy the following from the provided URL: klaviyo1m.aftership.com
- 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.
- 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.
- 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.
- Select the placeholder text next to Tracking Number and click the link button.
- 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' }}
- Click OK. Then, save your changes to the block by clicking Save.
- 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.
Outcome
You've now integrated AfterShip with Klaviyo and learned how to use your synced data.