Klaviyo - _kx and _stape_klaviyo_email

Hey There,

I know this probably is a little basis, but with the Klaviyo integration who does it deal with the identify basis?

Do people keep the klaviyo newsletter on site and then grab the _kx and if its not there use stape_klaviyo_email (Which is mapped to say {{email}}.

Does anyone use native shopify newsletters and catch the email address in GTMweb and write to cookies.

Also, can the stape klaviyo tag use the _kx?

Cheers
PS. sorry if its basis.
Chris

Do people keep the klaviyo newsletter on site and then grab the _kx and if its not there use stape_klaviyo_email (Which is mapped to say {{email}}.

  • the expectation is _kx comes as query parameter from the klaviyo generated email
  • we do look for it in the URL and we will use it for identification if no email is available
  • we also set stape_klaviyo_kx cookie if _kx query param was caught

I’m a bit confused as to the part with the newsletter, but here’s to hope the above clears it out for you. If not - please elaborate on what exactly you’re looking for

1 Like

Thanks for the quick response dan.

Kind of helpful on parts, I can see stape_klaviyo_kx in the cookie as well.

I guess I am trying to figure out the best way to capture identifiers or emails, should I use the klaviyo newsletter to get the email, and then pass that to Stape (assume its in cookies), and how would it get the email from the Klaviyo form?

I guess I am trying to marry up the current onsite klaviyo (from the standard integration) and make sure those events flow like they currently do via the stape integration.

And I am trying to figure out how I would get the identifier that was previously from the Klaviyo integration into the stape integration, or does that tag on serverside do that already?

** note the cookie data seems to be under .klaviyo.com as the domain.

Or the cookie __kla_id, how does this work with the GTMs tag? will it use the one from your domain or the klaviyo domain?

Chris,

  1. Cookie set by external domain wouldn’t be accessible to sGTM, that’s the very definition of 3d party :slight_smile:

  2. We’re not using the other one as well, the expectation is you have Active on Site events set up, so if anyone lands with _kx it will all be handled and cookies set by the tag will be used.

you could whip up a Cookie Monster instance on the server and set stape_klaviyo_kx off of __kla_id values, that is if you’re looking for a ‘migration’ kind of thing. I am not 100% sure those are same ids in principle though.

Hey @Dan

yeah I understand the cookie side, kind of part of what im trying to figure out.

ok, so to identify really you need one of the following:

  • Email address from somewhere (or ID)
  • _kx from an email

Does the _kx get automatically added to the cookie under stape_klaviyo_kx when klaviyo fires?

can the stape.io klaviyo tag fire if lined up the an event but doesnt have an email (but has stape_klaviyo_kx)?

sorry for all the questions,

Does the _kx get automatically added to the cookie under stape_klaviyo_kx when klaviyo fires?

cookie is set if your page_location has _kx when tag fires, yes

can the stape.io klaviyo tag fire if lined up the an event but doesnt have an email (but has stape_klaviyo_kx)?

yes

I can only add that I would definitely recommend saving and using email whenever it’s available. So using this after signing up for an email is a good idea.

awesome! thanks!

perfect

Hey Alex,

Thanks, we are in the process of working this out atm, we are kind of pulling down two paths

  • store them in the cookie
  • Create/user a userID, and then pass the data to stape store, and then tranform on the return.
  • same as above with another database

I think privacy wise, im more inclined to has a userID or such and then store off in stape store.

Sorry to hijack this thread, but I wanted to clarify something.

The _kx URL parameter seems to be a much longer string than the “Klaviyo Profile Id” that I have worked with when making API calls until now (unrelated to sGTM).

Therefore, passing the _kx value as the “Klaviyo User Id” seems confusing. Does the Klaviyo stape.io template convert the _kx value to a user (profile) id, or is there a step I am missing on the client side to retrieve or convert it?

For example, for a test profile, when I click on a link within an email, I see _kx = TmPjSrtzlhU4avsNkuCOpLEKBkkRvs5A_Vgw8E9-5uTL5Pk-ijxXj862593Dc3tavT54CXQ19P9ikICmXHSxPw-0IPyNxXlBxTdj0ZySfBA.<public-key>.

But if I look up the Profile Id within Klaviyo, I see 01HZ6HHGABNZBNAK4DT9XSGS1Y.

I think _kx gets sent with the Stape klaviyo integration, and Klaviyo matches it on their end

1 Like

Yeah, i think you’re right. The _kx value is actually converted by the Active on Site call. As long as you pass the value to the Data Client from the web GTM container…? Which is easy enough.

I should have searched first. To confirm:

I was just confused because if you make an API call using Postman, for example, to Klaviyo, you can use the in-platform, unencrypted Profile ID to directly access a profile instead of using an email address.

I recon you would have to pass it _kx (i’m still working on it at the moment, thus my question) as a customer property in the server.

You would probably want to store it somewhere as well (localStorage/cookie).

I would probably store in the cookie, then pull the value from the cookie instead of the localStorage or such.

although there is a cookie for this already, which i am curious where it came from, its called:

stape_klaviyo_kx

I wrote a Custom Javascript Variable that returns either the Query (URL parameter) or the saved cookie value. I set my own 1st party cookie when the page URL contains _kx. Then, that CJS variable is passed on to the client.

Maybe I don’t need to do that if a stape_klaviyo_kx variable is set, but I too can’t see when it is.

Maybe, I may have coded this as well. probs best to see what @Dan recons.

I mean you could def create a custom variable, and then store to cookie to use onwards.

really, I am more interested in the __kla_id now, which I think will need a call to klaviyo directly with the email and return that and save it.

Looking at the template code, there is a reference to the stape_klaviyo_kx cookie, but not when it is set. I will wait on this subject too. Thanks for you help!


I have another issue. Let’s say there was an event carried out by one “user” multiple times a day, but I only wanted to track one per user every 12 hours, how could I achieve that?

My client-side tag passes a var daysSinceEpoch = Math.round(now.getTime() / (1000 * 60 * 60 * 1)) value as the $event_id, but this is code I have inherited.

To me, it seems that it isn’t unique per person; it is only unique per event/time, and there is the possibility of lost data. It was my understanding that the event_id (or unique_id?) had to be unique per event (Create Event).

stape_klaviyo_kx is set on Active On Site events if URL of the page has _kx query param

3 Likes