Skip to main content

How to target Klaviyo lists, segments and properties in Mida

Connect Klaviyo and show an A/B test or a personalization only to the people in the lists and segments, and with the properties, you choose.

Connect Klaviyo and Mida can show an A/B test or a personalization only to the people you choose, by list, segment or profile property. You paste one API key and add a short piece of text to the links in your Klaviyo emails. There is no code to add to your site.

It also works the other way: Mida can save a survey answer, or any other attribute you choose, onto the profile in Klaviyo.

Plan: targeting by Klaviyo audience needs a paid Mida plan. Sending experiment data to Klaviyo is included on every plan.

How it works

The short version: you add ?md_kl={{ person.KlaviyoID }} to the links in your Klaviyo emails. Klaviyo fills in the person's profile ID when it sends. When they click through, Mida reads the ID, looks the profile up in your Klaviyo account, and saves their lists, segments and the properties you picked on their Mida visitor. Your targeting rules then read those values.

Why the extra step? Klaviyo does add its own tracking value to email links, but it is encrypted and only Klaviyo's script can read it. So Mida needs a value it can look up.

A finished link looks like this before Klaviyo sends it:

https://yoursite.com/pricing?md_kl={{ person.KlaviyoID }}

After the visitor lands, Mida removes md_kl from the address bar, so it is not left in a link someone might copy and share.

What Mida copies

Data

What is copied

Name in Mida

Segments

Every segment in your account, saved as true when the person is in it and false when they are not. Always on.

klaviyo_segment_ plus the name, for example klaviyo_segment_repeat_buyers

Lists

Every list in your account, saved the same way. Always on.

klaviyo_list_ plus the name, for example klaviyo_list_newsletter

Custom properties

Only the properties you tick.

klaviyo_ plus the property name exactly as it is in Klaviyo, for example klaviyo_Favorite Color

Country

Only if you tick it.

klaviyo_country

List and segment names are turned into lower case with underscores, so "Repeat Buyers" becomes klaviyo_segment_repeat_buyers. Property names keep their capitals and spaces. You do not have to work these out. Mida lists the exact name next to each one, and you can click it to copy.

When targeting applies

  • Targeting applies from the visitor's next page view, not the page they land on from the email. The lookup runs in the background so it never slows your page or delays a test.

  • Mida keeps a person's data for up to 6 hours before asking Klaviyo again. A change you make in Klaviyo can take that long to show up in Mida.

  • Mida remembers the person in that browser, so they stay recognized on later visits. Another browser or device needs its own click from an email.

  • Visitors who never clicked one of your Klaviyo emails, and whom Klaviyo's own script has not identified on your site, stay anonymous and do not match any Klaviyo rule.

Visitors recognized without an email click

Klaviyo's script on your site saves an encrypted ID in a cookie named __kla_id once Klaviyo has identified the visitor, for example after they sign up through a Klaviyo form or click a Klaviyo email. Mida sends that ID to Klaviyo to find the profile, so the person is recognized from their next page view.

  • This needs Klaviyo's onsite script (klaviyo.js) on your site, and the Klaviyo integration turned on in Mida.

  • Mida checks once per browser session. An ID that matches no profile is not asked about again for a day.

  • Mida keeps only Klaviyo's contact ID in the browser, never an email address.

  • An ID from an email link always comes first. With Strict Consent Mode, Mida waits for consent before reading anything.

Before you start

  1. Create a private API key. In Klaviyo, open Settings, then API keys, and click Create Private API Key. Give it Read access to Lists and Segments, and Read access to Profiles. If you also want Mida to save attributes onto profiles, give Profiles Full access instead. Copy the key. It starts with pk_.

  2. Make sure the Mida tag is installed on the pages your emails link to.

Connect Klaviyo

  1. In Mida, open Integrations and choose Klaviyo.

  2. Turn the integration on.

  3. Open the Config tab.

  4. Paste your key into Private API key and click Connect.

  5. When it says Connected, tick the properties you want to use under Attributes to bring in, then click Save attributes. You can pick up to 40.

Only an Owner or Admin can connect, replace the key, or disconnect. Lists and segments need no setup: all of them are brought in.

Add the ID to your email links

In each Klaviyo email or flow message, add this to the end of every link that goes to your site:

?md_kl={{ person.KlaviyoID }}

  • If the link already has a ? in it, use &md_kl={{ person.KlaviyoID }} instead.

  • If the link ends with a #section part, put the text before the #.

  • You can copy the exact text from the Klaviyo Config tab in Mida.

  • It only works on links in emails Klaviyo actually sends. In Klaviyo's preview the ID is not filled in.

If the ID does not fill in for one of your email types, you can use ?md_kl={{ email }} instead. Mida looks the person up once, keeps only their Klaviyo profile ID, and removes the value from the address bar. We recommend the profile ID where it works, because it keeps email addresses out of links.

Target a test or a personalization

  1. Open your test and go to Targeting.

  2. Add a Segment rule.

  3. In the attribute field, type the name from the Klaviyo Config tab.

  4. Choose a condition and a value, then save.

You want to reach

Attribute

Condition

Value

People in your "Repeat Buyers" segment

klaviyo_segment_repeat_buyers

Is true

Known contacts who are not in "Repeat Buyers"

klaviyo_segment_repeat_buyers

Is false

People on your "Newsletter" list

klaviyo_list_newsletter

Is true

People whose "Favorite Color" is blue

klaviyo_Favorite Color

Is equal to

blue

Everyone Mida has recognized from Klaviyo

klaviyo_list_newsletter (any list or segment)

Exists

A few things to know about conditions:

  • To target people who have something use Is true. To target known contacts who do not have it use Is false.

  • Anonymous visitors never match one of these rules, including "Is false" and "Does not exist". Mida knows nothing about them, so it leaves them out.

  • Text conditions are case sensitive. "Pro" and "pro" are different values.

  • All values arrive as text. Number and date conditions still work as long as the value looks like a number or a date.

For the full list of conditions, see How to use Segment & Event Filtering.

Send Mida attributes to Klaviyo

Mida can also save attributes onto the matching profile in Klaviyo. The usual case is a survey: a visitor answers "What is your team size?" on your site, and the answer is saved on their Klaviyo profile, where your emails and automations can use it.

There is nothing extra to connect. Klaviyo is written with the key you already pasted.

  1. Make sure your private API key has Full access to Profiles. A key with Read access only cannot save anything. If yours is read-only, create a new key and use Replace key in Mida.

  2. In Mida, open the Klaviyo Config tab. Under Send Mida attributes to Klaviyo, tick the attributes you want to send, then click Save. You can pick up to 20.

What you can pick from

  • Survey answers: every question with Save the answer to the visitor turned on, shown with the question and its survey.

  • Attributes on your visitors: names Mida has seen on your recent visitors, for example ones you set with mida.identify(), with how many visitors carry each.

  • If an attribute has not reached a visitor yet, type its name in Not listed? and click Add.

Klaviyo properties are free form, so a new name is simply added to the profile as a custom property.

How it behaves

  • It is only sent for visitors Mida has recognized from one of your Klaviyo emails. Anonymous visitors are never sent.

  • If a visitor answers first and is recognized later, the answer is sent as soon as they are recognized.

  • Nothing is sent until a name is on the list. Mida never sends an attribute you did not list.

  • Mida never creates a new profile in Klaviyo. It only updates ones that already exist.

  • The same value for the same profile is sent once an hour at most.

  • A value overwrites whatever was there before.

To stop, untick everything and click Save.

Test that it works

  1. Pick a list or segment that you are in yourself, and create a test that targets it.

  2. Add the link text to an email and send it to yourself as a real send, not a preview.

  3. Before you click, hover over the link in your inbox. You should see md_kl= followed by a 26-character ID. If you see the curly braces instead, Klaviyo did not fill it in.

  4. Click the link in a normal browser window. Mida removes md_kl from the address bar once the page loads.

  5. Go to another page on your site, or reload. You should now be in the test.

Privacy and consent

  • Mida copies only what is listed above and the fields you tick. Nothing else is read into Mida.

  • In the other direction, Mida sends Klaviyo only the attributes you list under Send Mida attributes, and only for recognized visitors.

  • The values are saved on the visitor in Mida and used for targeting only. They are not sent back to the visitor's browser.

  • If you use Strict Consent Mode, Mida does not read or store the contact ID until the visitor gives consent. If consent is withdrawn, the stored ID is removed from the browser.

  • Mida never creates a visitor from a Klaviyo lookup, so this does not add to your monthly tracked users.

  • Your API key is encrypted at rest and never shown again after you paste it. Mida reads from Klaviyo with it, and writes only if you list attributes to send.

  • When you disconnect, Mida deletes the stored key and stops looking people up. Values already saved on visitors stay there, but they are no longer refreshed.

Limits

Limit

Value

Properties you can bring in

40 per project

Length of a property value

200 characters. Longer values are cut.

Lists and segments in your account that Mida tracks

About 150 of each

How long a person's data is reused before Mida asks Klaviyo again

Up to 6 hours

New people Mida looks up

About 25 a minute

Klaviyo limits how many requests an account can make each minute, and Mida stays under that. Right after a large campaign, some visitors may be recognized a few page views later than usual.

Troubleshooting

What you see

What to check

"Klaviyo rejected this key"

You need a private API key that starts with pk_, with Read access to Profiles, Lists and Segments. The 6-character public key will not work.

The link in my inbox shows {{ person.KlaviyoID }} as text

The email was a preview, or that email type does not fill in the ID. Send a real email, or use ?md_kl={{ email }}.

I clicked the email but I am not in the test

Targeting starts on the next page view. Load a second page. Also check the link had md_kl in it and check the test's other targeting rules.

A property is missing from the list

Mida builds the list from one of your profiles. If that profile does not have the property, it is not shown. Contact us in the chat and we will help.

I changed someone in Klaviyo and Mida has not noticed

Mida reuses a person's data for up to 6 hours. Klaviyo can also take a while to update segment membership.

The card says "Needs attention"

Klaviyo stopped accepting the key, usually because it was deleted. Click Replace key and paste a new one.

"Klaviyo would not let this API key write"

The key has Read access to Profiles only. Create a key with Full access to Profiles and use Replace key.

A survey answer is not showing up in Klaviyo

Check the answer is ticked under Send Mida attributes and that the visitor clicked one of your Klaviyo emails, with md_kl on the link, in that browser.

Sending experiment data to Klaviyo

Separately from all of the above, when the integration is turned on, Mida sends each visitor's experiment and variant to Klaviyo as an event, so you can build segments and flows from what people saw. That part works through the Klaviyo script on your site and does not need the API key.

FAQ

Does this work for visitors who never opened my emails?

Only if Klaviyo's own script identified them on your site, as described in "Visitors recognized without an email click". Everyone else is anonymous until they click a link from one of your Klaviyo emails.

Do I need to change my emails?

Yes. Klaviyo does not put a usable ID on links by itself, so you add the short text above to your links.

Will it slow down my site?

No. The lookup happens in the background after your page and your tests have loaded.

Can I connect more than one email platform?

Yes. A project can connect several, for example HubSpot as your CRM and another tool for email. Each is connected and set up on its own card. A visitor recognized by more than one gets each platform's data side by side, and an attribute you send goes to every platform that lists it.

Did this answer your question?