Customer Tracking

This post is also available in: Czech Polish

When it comes to marketing automation, Customer Tracking is a core part of what’s going on under the hood. From tracking viewed products to behaviors, the data that fuels what Samba can do is all based on tracking your visitors and customers.
So how does Samba do this? It’s all made possible by a tracking script, which is integrated with your e-shop, called SmartPoint.


SmartPoint integration ensures your ability to evaluate anonymous data regarding the behaviors of those people visiting your e-shop. This includes:

  • Viewed products
  • Login information and details
  • Checkout process
  • Cart interactions
  • and more

So what is SmartPoint exactly?

  • It’s a basic tracking script
  • Provides information about visitors and customers
  • Connects data from multiple devices thanks to a saved cookie

Smartpoint Functions


  • Provides information about the customer’s ID
  • Makes it able to connect a customer to their shopping history


  • Provides information about a customer’s orders and the included items
  • Sends a signal to Samba immediately after an order is finished


  • Provides information about the content of a cart
  • Makes it able to activate an Abandoned Cart trigger

productId() (Optional)

  • Use this, in case of product URLs in your feed, are not consistent with active URLs on your website
The most common mistakes

Take a look at the most common problems that you can encounter while integration your shop and Samba. The link to the article is here.

Integrating SmartPoint

You have two general options for integrating SmartPoint:

  • Direct Integration via the coding of your website/e-shop (i.e. into the header script)
  • Google Tag Manager (GTM) – used for managing tracking codes and advertisement scripts
Blocking trackers

Google Tag Manager containers are currently blocked, for example, by the Ublock extension for Firefox and also by the “Block trackers” option in Opera. Therefore, we recommend to deploy our scripts directly without using GTM.

Direct integration

If you want to add SmartPoint through direct integration, first go to your Samba panel and navigate to your settings (click the gear on the top right). From there, click “Implementation” and expand the “Customer tracking” options. 

Click on the “SmartPoint” option and you’ll be presented with a tracking script (see example below) that you would need to add onto every page of your website. Again, an optimal means of doing this would be in the code of your header.

The standard form of the script looks like this:

<script async src="*YOUR-ID*"></script>

where *YOUR-ID* is your unique track point ID.

Validating direct integration

Open a console, go to Network – XHR and search for the save-action object.

If you integrated the SmartPoint correctly, the diffAnalytics object should be available. Write diffAnalytics into the console and press Enter.

Asynchronous integration

If you need to integrate the SmartPoint in the asynchronous way (in GTM for example), we recommend you to integrate all the other scripts via the onload queue.

var _yottlyOnload = _yottlyOnload || []
_yottlyOnload.push(function () {
    console.log("samba is ready") 

It is essential to use only the push method (no other way of array manipulation ), because after the script initialization, the _yottlyOnload variable will be exchanged for an object with its own push method, which immediately calls the callback function.

Javascript methods


  • customerId (string) – customer ID, which is the same as the ID in customers feed.
  • call this function every time the customer is logged in. (with every page load, not only with the first login)
  • if the customer isn’t logged in, don’t call the method at all. Especially do not call the method with empty string or the default value (“undefined” for example), which would lead to wrong evaluation of customers data.
  • Samba will automatically process back even those IDs that are not available in the customer database at the time of the call, but will appear there later. This is useful, for example, to use the customerLoggedIn method immediately after creating an order with customer’s registration.

Example of calling customerLoggedIn

Customer with ID “1234” is logged in.


Integration validation customerID

Open the console, go to Network. one of the requests save-action should contain customerId in „attachment“ after every page load done by logged in customer.

Pay attention to the spelling – customerId must be in the same format as CUSTOMER_ID in the customers feed.


  • orderInfo = { content: orderItems }
  • orderItems – array of bought products in format: { productId: "product-id-1", price: 20 }
  • productIdmust be the product ID from your products feed.
  • price – current price of the product, or the sum of all the items with the same ID (tax included). For example one piece of “product-id-1” costs 1 dollar and the customer bought two pieces of this product, so the price is going to be 2 dollars.

This script helps Samba to analyse the performance fot the web personalization. This is why it’s important to call this method when an order is made (on the thank-you-page).

The number of “click-throughs” is measured automatically, if the URL address of the product contains yottly_online.

Example of calling order

Customer bought one shampoo for 3 dollars, and two pieces of the same soap for 1,50 dollar a piece:

var order_content = [
   { productId: "shampoo-1", price: 2 },
   { productId: "soap-1", price: 3 }
diffAnalytics.order({ content: order_content })

order integration validation

Open the console and go to Network. As soon as the customer finishes an order (and the thank-you-page is loaded), one of the save-action requests should contain orderSubmitted in attachment.

Pay attention to the spelling – productId must be in the same format as product_ID in the product feed.


  • cartContent – { content: cartItems , onOrderPage:boolean}
  • cartItems – array of products in the cart in format: { productId: "product-id-1", amount: 2 }
  • productIdmust be the product ID from your products feed
  • amount – the number of pieces of the product in the cart
  • onOrderPage – optional boolean identificator, if the customer is in the process of finishing an order. If it’s not filled, Samba works with the false value.

This script helps Samba to analyse customer interaction with the shopping cart and is essential for the Abandoned cart trigger. That is why we recommend to call this method with every pageload (= on every single webpage). The contact array contains all products that are contained within the cart.

On the page, where customer finishes the order, call the method with parameter onOrderPage=true. This identificator helps us to recognize pages, where the order is finished and potential redirect to payment gateway, etc.

When the customer finishes an order (on the thank-you-page), call the method with empty content: content=[] (together with the order method).

Example of calling cartInteraction

Example 1
Customer has one shampoo and two pieces of the same soap in the cart, and just got to the second step of the order process.

var cart_content = [
   { productId: "shampoo-1", amount: 1 },
   { productId: "soap-1", amount: 2 }
var onOrderPage_value = true 
diffAnalytics.cartInteraction({ content: cart_content, onOrderPage: onOrderPage_value })

Example 2
Customer just finished an order:

var cart_content = [] 
diffAnalytics.cartInteraction({ content: cart_content})

cartInteraction integration validation

Open the console and go to Network. After the page loads, one of the save-action requests should contain cartInteraction in attachment.

Example 1
Customer loaded 2. step of order:

Example 2
The thank-you-page just loaded and customer finished an order.

Pay attention to the spelling – customerId must be in the same format as CUSTOMER_ID in the customers feed.

diffAnalytics.productId(productID) [optional]

  • productID – string
  • It is product ID which is compatible with Samba product feed. The ID helps Samba to pair the unknown products URL.
  • Call this method whenever the customer visits the detail of a product.

In case product URLs in your feed are not consistent with active URLs on your website, product tracking needs to be implemented by calling the productId(productID) method of the base diffAnalytics object when a visitor visits the product detail with productID as ID. It is not necessary to call this function if you have the SmartPoint implemented correctly and Samba is able to recognize all products using their URL.

Full example:

Customer visited product ID “a1234”.


Validate your implementation

Go to the browser console, select Network and one of the save-action requests should contain productId in the attachment when the customer visits the detail of a product. Please pay attention to correct spelling.


This post is also available in: Czech Polish

Updated on August 5, 2022

Was this article helpful?

Related Articles