BuyerGenomics’ Universal Touch System tracks consumer behavior in real time. This data can be used to predict what each individual is most likely to do next, and autonomously send messages designed to achieve desired conversions.

Understanding and acting upon this data in real time plays a huge role in many marketing tactics, including window shopping (a powerful AutoPilot action), rescuing abandoned carts, determining customer value, and tracking shifts along the Buyer Lifecycle.

Implementation Overview

The following provides clear instructions to install the BG Universal Touch System’s JavaScript API on your web pages in order to ingest real-time visitor- and buyer-interaction data into BuyerGenomics.

Separate code is provided to track each of the following:

  1. PageView Tracking - To be installed on every page of your site to track the visitor across pages. This tracks which page a visitor is on, device type, source, timestamp, and browsing duration.

  2. Product and Category PageView Tracking - To be installed on every product and category page of your site. This is used to track the product and product category viewed by the visitor.

  3. User Tracking - Used to identify visitor information (i.e., PII or Personally Identifiable Information). Can record first name, last name, email address, street address, etc.  Such data will be tracked only if some PII is provided. Used in conjunction with PageView Tracking

  4. eCommerce Cart Tracking - Code to track visitor cart content, such as product SKU number, product name, product category, price, quantity, and other attributes, such as color and size.

  5. eCommerce Transaction Tracking - Tracks transaction information such as total amount paid, shipping paid, tax paid, and discount amount. Used in conjunction with eCommerce Cart Tracking.

Example JavaScript code installations for category page, cart page, and order confirmation page are provided at the end of this document.

You will need two different credentials: 

  • Developer Brand ID and API Key

  • Production Brand ID and API Key

You will need your Developer Brand ID and API key in order to test your implementation. These will send data to your staging BuyerGenomics account. Contact your account manager to get your staging account.

When you are ready to move your implementation to production, use your production Brand ID and API key to send data directly to your live BuyerGenomics account. Only implement the ID and key after your implementation has been sufficiently tested and QA’d. 

PageView Tracking

PageView tracking is used to track what page a visitor views, when they view it, how they get there, and what they use to view it.

Basic PageView Tracking is required on all pages of your site and automatically records information like page, source, device, browser, language, timestamp, and browsing duration.

Add the following code to the head of each HTML page, just before </head> tag: 

<script src="https://api.buyergenomics.com/lib/traqbot-v1.min.js"></script>


Add the following code to the body of the page, just before </body> tag:

<script>
  var BGBot = new BuyerGenomics.tracker("API_KEY.BRAND_ID"120true);
  BGBot.TrackView();
</script>


Product and Category Tracking

Product and Category Tracking is used to record specific products and categories viewed by the visitor, in addition to the details collected by PageView Tracking. 

Add the following code before “BGBot.TrackView()” to track additional product and category information:

BGBot.SetViewDetails("CATEGORY NAME","PRODUCT NAME");


User Tracking

If you know who your customer is or have any additional personally identifiable information, track it by adding the following code before “BGBot.TrackView()”:

//create new customer
var customer = new BuyerGenomics.pii("FIRST NAME""LAST NAME"
                                     "EMAIL@ADDRESS.COM");
//add more information
customer.SetAddress("ADDRESS1""ADDRESS2""ZIP"
                    "CITY""STATE CODE""COUNTRY CODE")
customer.SetPhone("PHONE NUMBER");
//add customer to the tracker
BGBot.SetVisitor(customer);


Note: For the data field that you do not have, pass an empty string (e.g., “ “).


eCommerce Cart Tracking

Add the following code after “BGBot.TrackView()” on the page that displays the cart to track which products added to the cart:

//add new item
var item1 = BGBot.AddToCart("PRODUCT SKU""PRODUCT NAME", QTY, PRICE);
var item2 = BGBot.AddToCart("PRODUCT SKU""PRODUCT NAME", QTY, PRICE);

//add optional item attributes
item1.AddAttr("category""CATEGORY NAME");
item1.AddAttr("color""COLOR NAME");
item2.AddAttr("category""CATEGORY NAME");

//track the cart, true means that the whole cart is listed
BGBot.TrackCart(true);


eCommerce Transaction Tracking

Replace “BGBot.TrackView()” line with the following code on the Order Confirmation Page (e.g., your “Thank You” page):

  1. Insert User Tracking code

  2. Insert eCommerce Cart Tracking code (without “BGBot.TrackCart(true);”)

  3. Insert the following code:

//TOTAL_AMOUNT= total amount the user paid, typically sum of (item price * qty) + SHIPPING_AMOUNT + TAX_AMOUNT
//DISCOUNT_AMOUNT = any discount that customer got
BGBot.SetEcommerceData(TOTAL_AMOUNT, SHIPPING_AMOUNT, 
                         TAX_AMOUNT, DISCOUNT_AMOUNT);
//track order. THIS SHOULD BE THE SAME AS YOUR GA ORDER ID
BGBot.TrackOrder(ORDER_ID);


Examples

The following code below provides examples of proper implementations of the BG Web Tracking JavaScript API. 

Use these examples to ensure that the format, syntax, and placement of your implementation is correct and follows best practice.

Category Listing Page

<html>
<head>
<!-- ... //-->
<script src="https://api.buyergenomics.com/lib/traqbot-v1.min.js"></script>
</head>
<body>
<!-- a lot of HTML //-->
<script>
  var BGBot = new BuyerGenomics.tracker("API_KEY.BRAND_ID"120true);
  BGBot.SetViewDetails("Shirts","");
  BGBot.TrackView();
</script>
</body>


Cart Page

<html>
<head>
<!-- ... //-->
<script src="https://api.buyergenomics.com/lib/traqbot-v1.min.js"></script>
</head>
<body>
<!-- a lot of HTML //-->
<script>
  var BGBot = new BuyerGenomics.tracker("API_KEY.BRAND_ID"120true);
  BGBot.TrackView();
//------------cart listing below------------------
//add new item
  var item1 = BGBot.AddToCart("2344""T-Shirt"119.95);
  var item2 = BGBot.AddToCart("2311""Ring"111.99);
//add optional item attributes
  item1.AddAttr("category""Shirts");
  item1.AddAttr("color""White");
  item2.AddAttr("category""Accessories");
//track the cart
  BGBot.TrackCart(true);
</script>
</body>


Order Confirmation Page

<html>
<head>
<!-- ... //-->
<script src="https://api.buyergenomics.com/lib/traqbot-v1.min.js"></script>
</head>
<body>
<!-- a lot of HTML //-->
<script>
  var BGBot = new BuyerGenomics.tracker("API_KEY.BRAND_ID"120true);
//
//we do not track view on this page if transaction tracking is enabled
//
//create new customer
  var customer = new BuyerGenomics.pii("John""Doe""john@example.com");
//add more information
  customer.SetAddress("121 Main St""Floor 3""10001"
                      "New York""NY""US")
  customer.SetPhone("6461111111");
//add customer to the tracker
  BGBot.SetVisitor(customer);
//------------cart listing below------------------
//add new item
  var item1 = BGBot.AddToCart("2344""T-Shirt"119.95);
  var item2 = BGBot.AddToCart("2311""Ring"111.99);
//add optional item attributes
  item1.AddAttr("category""Shirts");
  item1.AddAttr("color""White");
  item2.AddAttr("category""Accessories");
//TOTAL_AMOUNT=$31.94 + $10 + $2.55
//DISCOUNT_AMOUNT - $5
  BGBot.SetEcommerceData(44.49102.5510);
//track order 
  BGBot.TrackOrder("1455543")
</script>
</body>