Skip to main content
Solved

Added "Product Viewed" with GTM but company_id where the tag is send is wrong

  • December 14, 2020
  • 6 replies
  • 451 views

Forum|alt.badge.img+2
  • Contributor I
  • 2 replies

Hi all,

Could you please help?

We have integrated Klaviyo into 2 Shopify plus stores.

We are getting most data except Product Viewed and Add to Cart. 

I have added the above 2 tags through GTM using the below code snippet: (please have in mind the base Klaviyo tag is installed directly in the theme)

<script type="text/javascript">
   var _learnq = _learnq || [];
   var item = {
     "Name": "{{dlv - Product View - Name}}",
     "ProductID": "{{dlv - Product View - Product ID}}",
     "ImageURL": "{{DOM - PDP - Image URL}}",
     "SKU": "{{dlv - Product View - SKU}}",
     "URL": "https://{{Page Hostname}}{{Page Path}}",
     "Brand": "{{dlv - Product View - Brand}}",
     "Price": "{{dlv - Product View - Price}}",
     "CompareAtPrice": "{{dlv - Product View - Variant Compare At Price}}"
   };

   _learnq.push(["track", "Viewed Product", item]);

   _learnq.push(["trackViewedItem", {
     "Title": item.ProductName,
     "ItemId": item.ProductID,
     "Categories": item.Categories,
     "ImageUrl": item.ImageURL,
     "SKU": item.ID,
     "Url": item.URL,
     "Metadata": {
       "Brand": item.Brand,
       "Price": item.Price,
       "CompareAtPrice": item.CompareAtPrice
     }
   }]);
 </script>

however in one of the stores I can see the company_id is wrong in the developer tools > Network so data is not sent to the right Klaviyo account.

I would expect it to go to API key / Site ID (MY API KEY), but it goes to another API Key

 

How could I make sure that data is sent to the correct public API key / Site ID since the base Klaviyo tag is installed directly in the theme and not in GTM?

 

Thank you in advance

Dim

Best answer by dim78

In case anyone experiences the same issue, reach out to Klaviyo.

In my case, there was an integration issue, resolved by Klaviyo team

View original
Did this topic or the replies in the thread help you find an answer to your question?

6 replies

Forum|alt.badge.img+2
  • Author
  • Contributor I
  • 2 replies
  • December 15, 2020

It looks like on page load there are 4 instances with different company ids.

The correct is the 3rd one but it is not picked up

 


cassy.lee
Forum|alt.badge.img+9
  • Klaviyo Alum
  • 271 replies
  • December 15, 2020

Hi @dim78

Based on the details you’ve provided, I’d recommend reviewing your Shopify integration settings, or looking through this guide to manually installing Klaviyo.js. I’d suggest looking through your main site’s template theme and check what the company ID is in the active onsite snippet (should look like below and “API_KEY” should be your store)
 

<script type="text/javascript" async 
 src="https://static.klaviyo.com/onsite/js/klaviyo.js?company_id=API_KEY"></script>


It should have “YOUR API KEY” as the Public API Key, so if it’s not, you can go ahead and make that change. 

If the API Key in the Active Onsite code snippet is the correct one for your store, can you drop a comment back and let us know? There may be other causes to explore. 

Thanks, 
-Cass. 


Forum|alt.badge.img+2
  • Author
  • Contributor I
  • 2 replies
  • Answer
  • December 16, 2020

In case anyone experiences the same issue, reach out to Klaviyo.

In my case, there was an integration issue, resolved by Klaviyo team


cassy.lee
Forum|alt.badge.img+9
  • Klaviyo Alum
  • 271 replies
  • December 17, 2020

Thanks so much for sharing this update with the Community, and glad to hear you were able to get this resolved! 


Forum|alt.badge.img+5
  • Contributor II
  • 4 replies
  • September 24, 2021

Has the same integration issue. Can it be solve by just updating the integration settings by unchecking the first box  when integrating?


Dov
Forum|alt.badge.img+61
  • Klaviyo Alum
  • 1493 replies
  • September 27, 2021

Hello @karen1628,

Unchecking the box “automatically add Klaviyo onsite javascript” in the integration settings could work, but it is not a 100% reliable solution.

With that said, if you are noticing a single Klaviyo javascript snippet with the wrong API key on your site, I recommend updating it using the advice outlined by @cassy.lee in her last post -- locate the onsite javascript snippet and updating the public API key to the public API key of the correct Klaviyo account.

<script type="text/javascript" async src="https://static.klaviyo.com/onsite/js/klaviyo.js?company_id=API_KEY"></script>

If you are noticing multiple Klaviyo javascript snippets with different API keys, I recommend reaching out to to support and providing them with the public API key of the Klaviyo account you want the events to be sent to. They will be able to remove the other keys from your site.

I hope that is helpful!