Skip to main content

Let’s say I track product and category views, add to cart etc before the user has been identified.

The user then goes to checkout - where we will do an identification after she provides her email.

When we look in the profile in Klaviyo, there are only activities logged after the identification. The previous activities are “lost”.

 

Is this by design?

Hi @ViktorBergman,

Thanks for sharing this with us.

For the sake of this, let’s call both “Add to Cart” and the checkout process two separate “identification” methods. They both “identify” the individual but in slightly different ways and they operate completely independent from one another. This is to say, the order of identification i.e. whether they add to cart first or start checkout first (or vice versa) should not matter, we should be logging all events at all points in time.

To elaborate on the methods themselves:

“Add to Cart” relies on the user being cookied to identify them

 A visitor can be identified via cookies when they: 

  • Fill out a Klaviyo signup form 
  • Click a link from a Klaviyo email 

If a user performs either of the above actions, we’ll track the “Add to Cart” event for that user.

Other events that rely on this process are Viewed Product and Active on Site, they’re all web-tracking events.

In contrast, at checkout, and as you pointed out, the “identification” method is the email input field.

If you notice your add to cart events are not being logged on the profile that could be due to another reason. I recommend browsing the community for troubleshooting (here’s a post on Added to Cart to help you get started).

I hope that helps clear things up.

 


Hi @Dov,

 

I’m guessing my question is more in the line of past events being tracked prior to the cookied user is identified.

  1. User logs on anonymously and gets cookied as e.g. XYZ123
  2. Visits product X
  3. Adds product X to cart
  4. Fills out Klaviyo signup form
  5. Visits product Y
  6. Adds product Y to cart

Since the user is on the same cookie I would expect product X to be visible for that profile, however it seems like only events happening after step 4 above gets saved.


Nobody knows anything about this?


Hi @ViktorBergman,

Thanks for your follow-up note.

The Klaviyo cookie isn’t applied in the case of a log-in. Only when a user fills out a Klaviyo sign-up form or clicks through a Klaviyo email.

Under normal circumstances where an email address is used at sign-in, there will only be activity being logged if you have identify tracking installed.

Specifically, you can identify a profile with their email address using this snippet:

<script>
  var _learnq = _learnq || r];

  _learnq.push(n'identify', {
    // Change the line below to dynamically print the user's email.
    '$email' : '{{ email }}'
  }]);
</script>

Also, maybe you can clarify what you mean by “logs in anonymously”. If a user is logging in from an incognito browser or there is no email address used in the log-in, i.e. just a username on the log-in page, then Klaviyo cannot capture information about that individual after signing in. This is because Klaviyo uses the email address as the primary identifier for the profile. Without it, we won’t associate the activity with the Klaviyo profile. 

 


Thanks @Dov ,

I should clarify, when I mean “logs on anonymously” I mean that they visit the site.

The user visits the site and gets cookied (there is a __kla_id cookie present). We start sending events. Those events are lost when we identify the same user (wether they signup on a form or if we call identify manually). Only events tracked AFTER the identification gets stored?

Let’s say the only time we call Identify on the site is when they have filled out the checkout (i.e. we can send and abandonded cart). We do not know anything about what this user did on the site before they were identified - even if they are cookied with the exact same __kla_id)


Hi @ViktorBergman,

Thanks for your reply.

If the user used the same email address in both circumstances (cookied prior to starting the checkout due to some web tracking activity, and subsequently started the checkout) all events, both before and after the checkout event, should be logged on the same profile. If you are noticing that is not the case, then I recommend contacting our support team to have a closer look for you. If you decide to contact support, please supply them with an example email address which has run through the aforementioned steps (cookied on the site, started a checkout) and they’ll have a look for you.

I hope the explanation above helped clarify the default behavior at the very least.

Thanks for being a member of our community.


@Dov 

The point was when the user did not identify themselves before checkout, only when they provide us with their email address upon checkout. I will interprete this conversation as that no events occuring from cookied users before being identified are saved, meaning there are no traces of what happened before they identified themselves and abandonded the checkout. I’ve seen this behaviour in both custom integrations and the official Shopify integration.

Thanks.


I think the situation described by the OP (please correct me if I’m mistaken) is as follows:

  • Unidentified user visits website eNo email is associated]
  • Klaviyo uses a cookie to track that user’s website engagements (eg - product views, activity on sIte, add-to-cart, etc.)
  • That user EVENTUALLY -- either during the initial session or some future session that still has the same cookie -- does provide their email either through a signup form or by adding it during the checkout process
  • QUESTION
    • Do all of the actions tracked prior to receiving the email -- let’s call them the “cookie actions” -- get reconciled and attributed to the new Klaviyo user that will be idenitifed by the email they provided?
    • If “cookie actions” do NOT get attributed to the Email then they are basically “Lost” as has been alluded to previous posts.

I hope that the above is a clear breakdown of the use case that is in this thread. Thanks.


@Dov Can you please answer the above post? I am able to reproduce this behavior. 


Hi @AccelPay and @ViktorBergman!
 

I can hop in here to clarify - the events that are tracked prior to a profile being created/identified at checkout/sign-up form are not back-filled to the profile. It’s only the activity that occurs after the profile is identified as a Klaviyo profile that is tracked.

 

I’ll update the thread if this functionality changes in the future.

 

Best,

Brian


I ran into the same issue and was able to solve it using some custom code added to the Order Status page “Additional scripts” in Shopify settings → Checkout. Posting below in case it helps others.

 

To clarify, the issue is in the situation where the user does NOT enter their email into a klaviyo email box on the site and ONLY enters their email during the shopify checkout flow. In that situation, Klaviyo is not able to use the email provided during checkout to apply it back to the anonymous events that were tracked locally prior to checkout. This results in those anonymous, pre-checkout, events being lost. The code below will take the customer email that’s applied during checkout and apply it to a Klaviyo “identify” call that’s executed on the order “thank you” page. This allows Klaviyo to link the pre checkout anonymous events back to that email address.

<!-- Klaviyo script to link actions prior to checkout -->
<script
async type="text/javascript"
src="//static.klaviyo.com/onsite/js/klaviyo.js?company_id=YOUR_KLAVIYO_PUBLIC_API"
></script>

<script>
!function(){if(!window.klaviyo){window._klOnsite=window._klOnsite||t];try{window.klaviyo=new Proxy({},{get:function(n,i){return"push"===i?function(){var n;(n=window._klOnsite).push.apply(n,arguments)}:function(){for(var n=arguments.length,o=new Array(n),w=0;w<n;w++)oyw]=arguments;w];var t="function"==typeof o=o.length-1]?o.pop():void 0,e=new Promise((function(n){window._klOnsite.push(ii].concat(o,tfunction(i){t&&t(i),n(i)}]))}));return e}}})}catch(n){window.klaviyo=window.klaviyo||v],window.klaviyo.push=function(){var n;(n=window._klOnsite).push.apply(n,arguments)}}}}();
klaviyo.push(<'identify', {
'$email' : '{{ checkout.email }}'
}]);
</script>

 


@Brian Turcotte 

Curious why is everyone saying there isn’t a way to track events prior to the user being identified, only events after the users has been identified? Isn’t there the anonymous visitor activity backfill feature in Klaviyo

 

I see that this help article was last updated in August 2023 (way before @dougj’s comment), so doesn’t that accomplish exactly this? 

 

I’m so confused. 


The problem is, unless you run the code I posed above, Klaviyo is never given the identifier (aka email) that it should link the pre checkout events to. The anonymous pre checkout events and the identified (email) checkout events live in two separate worlds until you join them together. My code links them together so that Klaviyo can join them into a single identified profile. Klaviyo themselves seem oblivious to this important Shopify use case. I spoke to their support about it and they were of no help, which was mind blowing since this is such an important use case for their customers (knowing your new customer flow).


Thanks @dougj, appreciate the explanation.

I have added your script into my store’s checkout page, really appreciate your openness is sharing the custom script you wrote for this. I sure it’ll help many

Just want to make sure I understand it correctly, the anonymous visitor activity backfill feature in Klaviyo backfills activities as long as 1) the visitor eventually puts their email into a sign up form using the browser while anonymous Klaviyo cookie is still active or 2) the visitor clicks on a Klaviyo email tracking link which opens onto the browser while the anonymous Klaviyo cookie is still active; however it does not backfill activities if a visitor doesn’t do any of those but does put in their email during checkout. And this is where you custom script will come in. Did I understand that correctly? 

 


Correct. The Shopify checkout flow is on a shopify owned domain (eg “shop.app/...”), not your shopify store’s domain. The Klaviyo cookie on your store’s domain that tracked the anonymous session events cannot connect it to the email entered on the shopify checkout domain. My thank you page script, which runs on your store’s domain, gets the customer’s email from the shopify liquid variable (“checkout.email”) and then applies it to the Klaviyo identity attribute which allows Klaviyo to connect those prior anonymous events to that identity.


I ran into the same issue and was able to solve it using some custom code added to the Order Status page “Additional scripts” in Shopify settings → Checkout. Posting below in case it helps others.

 

To clarify, the issue is in the situation where the user does NOT enter their email into a klaviyo email box on the site and ONLY enters their email during the shopify checkout flow. In that situation, Klaviyo is not able to use the email provided during checkout to apply it back to the anonymous events that were tracked locally prior to checkout. This results in those anonymous, pre-checkout, events being lost. The code below will take the customer email that’s applied during checkout and apply it to a Klaviyo “identify” call that’s executed on the order “thank you” page. This allows Klaviyo to link the pre checkout anonymous events back to that email address.

<!-- Klaviyo script to link actions prior to checkout -->
<script
async type="text/javascript"
src="//static.klaviyo.com/onsite/js/klaviyo.js?company_id=YOUR_KLAVIYO_PUBLIC_API"
></script>

<script>
!function(){if(!window.klaviyo){window._klOnsite=window._klOnsite||t];try{window.klaviyo=new Proxy({},{get:function(n,i){return"push"===i?function(){var n;(n=window._klOnsite).push.apply(n,arguments)}:function(){for(var n=arguments.length,o=new Array(n),w=0;w<n;w++)oyw]=arguments;w];var t="function"==typeof o=o.length-1]?o.pop():void 0,e=new Promise((function(n){window._klOnsite.push(ii].concat(o,tfunction(i){t&&t(i),n(i)}]))}));return e}}})}catch(n){window.klaviyo=window.klaviyo||v],window.klaviyo.push=function(){var n;(n=window._klOnsite).push.apply(n,arguments)}}}}();
klaviyo.push(<'identify', {
'$email' : '{{ checkout.email }}'
}]);
</script>

 

Doug thank you so much! I tried to set up this but with the “Additional Scripts” in the Checkout section being deprecated and not having shopify plus I don’t know where and how to add this script to make it work. I tried in customer events and with some apps but maybe I didn’t do it right. Could you help me?


Reply