Purchase Tracking

How to implement Bambuser's tracking library for Live Shopping purchase tracking

This document covers how to implement tracking of purchases to improve the quality of your Bambuser Live Shopping statistics.


Introduction

Implementing Bambuser’s tracking library for Live Shopping on your website gives you the most value out of your Bambuser Live Shopping performance statistics.

Since some actions related to the Live Shopping experience occur outside of the player - most notably purchases - Bambuser needs complementary information to provide a holistic view of how your live streams affect your sales.

For these purposes, Bambuser provides a JavaScript library you can use to send relevant data to your Live Shopping performance tracking.

Note

For instructions on how to embed a Live Shopping player on your site, please see our Player Integration Guide

The Live Shopping player will use the cookies below to track the user both in the player and whether an actual purchase was made via your checkout/order pages.

Disclaimer

Bambuser does not collect any personal data.

Cookies

Name Expiration date Description
_bamls_cuid 1 year Unique identifier for the merchant. Used as a common denominator for all tracking performed by Bambuser to easily enable reporting and dashboards per merchant.
_bamls_usid 1 year Unique identifier for a user. Used to attribute Bambuser statistics to a single site user.
_bamls_seid 30 min Unique identifier for a session in which a Bambuser show was watched. Used in tracking to attribute statistics to a single session.
_bamls_shid 30 days Unique identifier for a Bambuser show. Used to attribute statistics to a single show. This also - similar to source/medium in  Google Analytics - enables attribution of purchases (that do not occur within the embedded stream) towards the show.
_bamls_lits 30 days The timestamp for the last known interaction in a Bambuser show. This is used in conjunction with _bamls_shid to measure at what point in time after a user viewed a show, the actual purchase was made.

Prerequisites

  • You have access to edit code on your Order Confirmation Page
  • Order Confirmation Page should be on the same domain or subdomain of the page that the player is embedded on.

Implementing Purchase Tracker

1) Adding the tracking library

To assist you in tracking, Bambuser has created a JavaScript library that takes care of most things for you. 

Follow the steps below: 

Add the following script tag in the <head> section of order confirmation page (the page after you handle the checkout) on your website:

<script src="https://cdn.liveshopping.bambuser.com/metrics/bambuser.min.js"></script>

Loading library asynchronously

You can load the library asynchronously if you're careful and ensure that it’s ready when you call the method described below.

Adding library through Google Tag Manager

If you rather use Google Tag Manager, you can do that too! Add it by creating a "Custom HTML" tag and adding the script above.

2) Sending data to Bambuser

Since Bambuser only has control over what happens within the stream, we are unable to track purchases. As such, in order for us to be able to show you a comprehensive view of the performance of a stream, we need additional information regarding purchases.

Caution

Ensure that the tracking library mentioned above has finished loading when attempting to run the purchase function (or tag).

You can implement the purchase tracker function in 2 ways:

(First Method) Write your own JavaScript

Call the following method provided by the tracking library once a purchase has been confirmed; window._bambuser.collect(data)

// Your existing purchase handling function 
 function onPurchase() { 
 // [your own code here] 
	
 // Properties below should be named in this exact way 
 var data = { 
     event: "purchase", // value needs to be “purchase” 
     orderId: "12345", // the order id 
     orderValue: "12345", // total of all products in the order 
     orderProductIds: "1,2,3,4,5", // comma-separated string of all product ids in the order 
     currency: "USD", // the currency used for the order in [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) 
     country: "US" // the market of purchase in [ISO 3166 country codes](https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes) 
 }; 
	
 // Send the data to Bambuser 
 window._bambuser.collect(data); 
	 }

(Second Method) Use Bambuser Google Tag Manager Template

If you are using Google Tag Manager (GTM), we have a simple Custom Template that allows you to easily send purchases to us through GTM.

Does the GTM template already include the tracking library?

No, if you wish to use the GTM template, you still need to load the tracking library to the page separately. And make sure the tag is fired after the library is loaded.

  • 1. Create a Trigger for your 'OrderConfirmation' page
    This should trigger the tag when a successful order has been placed.
  • 2. Installing the Bambuser Live Shopping-tag
    Our tag has been deployed to the Google Tag Manager Community Template Gallery. To find it, you simply:
    • Go to "Templates" in the left-hand-side menu
    • Under "Tag Templates" in the "Templates" view that has now appeared, press the "Search Gallery" button
    • You should now see the "Import Tag Template" view. Either search for (search icon in the top right) "Bambuser Live Shopping" or simply scroll down until you find it and click on it.
    • You should now see the view below. Click "Add to workspace" and confirm our required permissions by pressing "Add" in the popup that appears. That's it!

      INFO

      We may update the tag. When we do, you will be notified in Google Tag Manager (and by us) that an update is available; please update if you see such a notification





  • 3. Create a new tag
    • On the Tags page, click on New create a new tag
      Create a tag of type "Bambuser Live Shopping" found under "Custom" when creating a new tag
    • Populating the Bambuser Live Shopping-tag

      The tag (which should be fired when a purchase occurs) needs 4 data points (likely from GTM variables) to send a purchase properly:
      • Order ID
        • Simply the ID of a Purchase/Transaction
      • Order Value
        • Total revenue, e.g. "1000" if a user purchases items that cost 1000 (currency provided next).
      • Currency
        • As the name suggests, the currency in which the Order Value was purchased
      • Product IDs
        • A comma-separated list of IDs of the product(s) that were part of the Order, for example, "111,222,333,444,555"

Troubleshoot

If you run a test order but cannot see the sales data under the show Stats page (in the dashboard), here is a checklist to find and address the issue:

  1. Confirm that the Bambuser purchase tracking script is fully loaded from https://cdn.liveshopping.bambuser.com/metrics/bambuser.min.js on your order confirmation page, before your purchase script/the GTM tag is fired
  2. Make sure you have watched a LiveShopping show in the same browser session and have the‍ necessary cookies set in your browser
  3. Watch the network calls when completing the purchase, there must be a metrics call to https://cl.liveshopping.bambuser.com/metric with 200 status. The request payload must contain the purchase data
  4. Check if there are any errors that don't let the purchase tracker script run

Note

Contact support@bambuser.com, mention that you have checked the above, and include your code/screenshots/guide on how to place test orders. Then we will be able to help you debug the issue.

Purchase Tracking FAQ

For legacy reasons, cookies are not created unless the onBambuserLiveShoppingReady() function is defined (even if we don't need it, an empty function will allow us to write the cookies when we open the player).

Google structured data tool successfully recognizes our JSON-LD data but Bambuser product scraper does not

There might be errors in JSON-LD data that Google Structured data tool does not complain about. Use https://json-ld.org/playground/ to check the validity of your JSON-LD data.

If everything still looks fine on your side, contact the support department at support@bambuser.com



Will purchase tracking work if the viewer has disabled cookies?

If the users have disabled cookies, the user experience will be the same, but purchase tracking will not work.

Are we tracking only the products which are added in the show as part of purchase tracking?

When a customer visits a live show, our Bambuser cookies are set and the purchase tracking starts from there.

Until the last cookie required for Purchase tracking to work expires (baml_shid - 30 days), all purchases made from a viewer will be linked to the last show they have watched.

What are orderProductIds and orderIds used for? How do you confirm they are valid?

As of right now, we do not check if the orderProductsId and orderId are actually valid. So a non-numeric string should be no problem.

  • orderID is currently only helpful for us to identify "duplicate rows" as sometimes customers send us duplicated data.
  • orderProductId helps us identify both correlations between what products were in a show relative to what was sold and to give us a list of how many of each item was sold.

They are there for potential future features to demonstrate better reports in the future.


Was this article helpful?