By default, Yusp only tracks 3 event types:


view events: when a product page is viewed

browse events: when a non-product page is viewed

rec click events: when an item in a recommendation box is clicked on 


In order to track purchases on your site as well, you need to implement a buy tracking code. It is highly recommended that you implement buy tracking for Yusp, because:


  • "Buy events" represent valuable, additional information that Yusp can use to further increase the accuracy of your recommendations.
  • By implementing buy tracking, you can track important additional metrics, such as revenue through recommendations / all revenues. 

To start to track buys with Yusp, you need to do the following:

  • Make sure your general Yusp tracking code is inserted into the header section of your checkout complete (or thank you) page.
  • Edit and paste the below script into the checkout complete page of your website. 

     

<script>
var _gravity = _gravity || [];
 // one buy event for each product bought
 _gravity.push({type: "event", eventType: "BUY", itemId: "12", unitPrice: "49", quantity: "1", orderId: "ord1118"});
 _gravity.push({type: "event", eventType: "BUY", itemId: "23", unitPrice: "5.25", quantity: "2", orderId: "ord1118"});
</script> 

     

Ideally, the script above generates one object per one item bought, which constitutes one Yusp buy event. These will be stored in your event database, alongside other events. 


In case you are using Google Data Layer in your success page, use the following template and place it after the data layer, or implement through Tag Manager:


<script>
var _gravity = _gravity || [];
dataLayer.forEach(function(o, i) {
   if(o["event"] === "transaction") {
      o["transactionProducts"].forEach( function (k, i) {
        _gravity.push({type: "event", eventType: "BUY",  itemId: k["sku"], unitPrice: k["price"], quantity: k["quantity"], orderId: o["transactionId"];
       })
  }
});
</script>