Skip to main content
ViktorBergman
Contributor II
Contributor II
January 11, 2022
Solved

Is activity saved before being identified

  • January 11, 2022
  • 16 replies
  • 1144 views

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?

    This topic has been closed for replies.
    Best answer by Dov

    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.

    16 replies

    Contributor II
    November 14, 2023

    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||[];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++)o[w]=arguments[w];var t="function"==typeof o[o.length-1]?o.pop():void 0,e=new Promise((function(n){window._klOnsite.push([i].concat(o,[function(i){t&&t(i),n(i)}]))}));return e}}})}catch(n){window.klaviyo=window.klaviyo||[],window.klaviyo.push=function(){var n;(n=window._klOnsite).push.apply(n,arguments)}}}}();
    klaviyo.push(['identify', {
    '$email' : '{{ checkout.email }}'
    }]);
    </script>

     

    Contributor I
    December 22, 2023

    @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. 

    Contributor II
    December 22, 2023

    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).

    Contributor I
    December 23, 2023

    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? 

     

    Contributor II
    December 24, 2023

    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.

    Contributor I
    June 10, 2024

    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||[];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++)o[w]=arguments[w];var t="function"==typeof o[o.length-1]?o.pop():void 0,e=new Promise((function(n){window._klOnsite.push([i].concat(o,[function(i){t&&t(i),n(i)}]))}));return e}}})}catch(n){window.klaviyo=window.klaviyo||[],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?