Manually Install klaviyo.js for Shopify Stores

Last updated at:


For customers who are concerned with their site's performance, they can manually install klaviyo.js in their Shopify theme files.

Only larger customers who experience very high web traffic, or sites that suffer from slow loading time for any other reason, should be concerned with manually installing klaviyo.js. Otherwise, we recommend customers to install klaviyo.js by checking the box on the Shopify integration settings page.

Install klaviyo.js in Your Shopify Store

To install klaviyo.js into your Shopify store, copy the snippet of code below, and paste it into your theme.liquid file.

  1. In the script below, be sure to replace 'API_KEY' with your Public API Key from your Klaviyo account.

    If you've enabled Customer Accounts for your store, you can add and extra script to identify your customers with the email they use to log in to your store.

    Again, be sure to replace 'API_KEY' with your Public API Key from your Klaviyo account. The full script will look like the following:

    <script async type="text/javascript"
     var _learnq = _learnq || [];
     if ('{{ }}') {
       _learnq.push(['identify', {
           '$email' : '{{ }}'

    After you've updated the code snippet, copy it, and move to the next step.

  2. Next, from your Shopify Admin click Online Store > Themes. From the dropdown click Edit Code.
  3. Search for the theme.liquid file. Click on the file to open it in the editor.
  4. Scroll to the bottom of the file and locate the closing </body> tag. Paste the first code snippet directly before the closing </body> tag. Click Save.
  5. Click Save.
  6. Switch back to your Klaviyo account. Click the Setup Web Tracking link in the account dropdown.setup-web-tracking.png
  7. Enter the URL for your Shopify store into the box. Click Next.
  8. Click the link that is generated. This triggers an Active on Site event in your Klaviyo account.

A green Data Received button confirms that your web tracking is set up correctly. 

Was this article helpful?
17 out of 36 found this helpful