Skip to main content
Solved

Troubles with viewed product on CommerceHQ platform

  • January 24, 2021
  • 1 reply
  • 100 views

Forum|alt.badge.img+2

Hey guys, I believe I may be having difficulties with the browse abandonment trigger for one of my stores. When i go into the metrics it doesn’t show it tracks. However it does track the site abandonment. 

Just wondering if there is a particular snippet i would have to add in commerceHQ or if the same snippet applies.

Just so you know, my store was migrated from shopify to commerceHQ.

Best answer by Paul S

Hi @Blythe_Adrian,

 

Not sure if you found a solution already but the snippet you would want to use if not already added for the Viewed Product metric is below.  

 

On your product page template, add a snippet like the following:

<script type="text/javascript">
   var _learnq = _learnq || [];
   var item = {
     "ProductName": "Winnie the Pooh",
     "ProductID": "1111",
     "SKU": "WINNIEPOOH",
     "Categories": ["Fiction", "Children"],
     "ImageURL": "http://www.example.com/path/to/product/image.png",
     "URL": "http://www.example.com/path/to/product",
     "Brand": "Kids Books",
     "Price": 9.99,
     "CompareAtPrice": 14.99
   };

   _learnq.push(["track", "Viewed Product", item]);
 </script>

You can additionally track the recently viewed item to a person’s profile under a “Recently Viewed Items” section by adding on the following snippet directly below the Viewed Product snippet above. For more information on how to use the “Recently Viewed Items”, check out this guide.

<script type="text/javascript">
   _learnq.push(["trackViewedItem", {
     "Title": item.ProductName,
     "ItemId": item.ProductID,
     "Categories": item.Categories,
     "ImageUrl": item.ImageURL,
     "Url": item.URL,
     "Metadata": {
       "Brand": item.Brand,
       "Price": item.Price,
       "CompareAtPrice": item.CompareAtPrice
     }
   }]);
 </script>
View original
Did this topic or the replies in the thread help you find an answer to your question?

1 reply

Forum|alt.badge.img+10
  • Klaviyo Employee
  • 101 replies
  • Answer
  • January 28, 2021

Hi @Blythe_Adrian,

 

Not sure if you found a solution already but the snippet you would want to use if not already added for the Viewed Product metric is below.  

 

On your product page template, add a snippet like the following:

<script type="text/javascript">
   var _learnq = _learnq || [];
   var item = {
     "ProductName": "Winnie the Pooh",
     "ProductID": "1111",
     "SKU": "WINNIEPOOH",
     "Categories": ["Fiction", "Children"],
     "ImageURL": "http://www.example.com/path/to/product/image.png",
     "URL": "http://www.example.com/path/to/product",
     "Brand": "Kids Books",
     "Price": 9.99,
     "CompareAtPrice": 14.99
   };

   _learnq.push(["track", "Viewed Product", item]);
 </script>

You can additionally track the recently viewed item to a person’s profile under a “Recently Viewed Items” section by adding on the following snippet directly below the Viewed Product snippet above. For more information on how to use the “Recently Viewed Items”, check out this guide.

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