Conversion tracking

    Conversion tracking


    Article summary

    You can track conversion events through the scripts provided by ShopLive. When a purchase meets the conditions below, it would be counted as a conversion.

    • A user watches a live (or replay) or short-form video for at least 3 seconds

    • Purchased products were also displayed on a live (or replay) or short-form video

    • the purchase happened within a maximum of 28 days from the date the user watches the product listed in the video

    Conversion is based on the last video the user watched, and live (replay) and short-form are recorded separately. So, if a purchase occurs, it will be recorded as a purchase conversion in both live (replay) and short-form respectively If the user watched both.


    sendConversionEvent

    The sendConversionEvent() function used on the purchase completion page records the purchase event using the product identifier of the purchased item as the key information. It maps this information to viewing data to record the correlation between viewing and purchasing.

    For logged-in users, the function recognizes the user of viewing and purchasing through user authentication, similar to the viewing process. For users who are not logged in, it links viewing and purchasing using the user identifier stored in local storage.

    Conversion Config Object

    Field name

    Type

    Description

    accessKey (required)

    String

    Account AccessKey

    eventType (required)

    String

    ‘purchase’

    products (required)

    Products

    Products object


    User Authentication

    userId

    It is used to authenticate users through commonly used User authentication functions and link purchase/viewing data.

    User object

    An object describing the content of a user.

    Field name

    Type

    Description

    userId

    String

    User ID is required for user authentication (This is not required for purchase conversion tracking.)

    userName

    String

    Your name

    anonId

    This is an anonymous ID that can be used to track purchase conversions. If you manage an identification value such as a device ID separately, you can enter this value as anonId to associate viewing/purchase data without user authentication. If you don't have a value to manage, you don't have to use it.

    <script type="text/javascript" src="https://static.shoplive.cloud/shoplive.js"></script>
    <script>
      // Shoplive init() with anonId as well as accessKey (init with anonId must be also on player page as well as purchase page)
      cloud.shoplive.init({
        accessKey: 'YOUR_ACCESS_KEY',
        anonId: 'USER_ANON_ID'
      });
    </script>

    Purchased products

    A list of purchased products is used for tracking purchase conversions.

    Product object

    An object describing the contents of a purchased product.

    Field name

    Type

    Description

    sku | productId | customerProductId (required)

    String

    One of the three values is required for product matching.

    purchaseUnitPrice

    Int

    Purchase price (use the price of the registered product when not filled)

    purchaseQuantity

    Int

    Number of purchases (if not filled in, it will be counted as 1)

    orderId

    String

    Order number (optional)


    Sample code

    SKU usage / Login user

    <script type="text/javascript" src="https://static.shoplive.cloud/shoplive.js"></script>
    <script>
      cloud.shoplive.init({
        accessKey: 'YOUR_ACCESS_KEY'
      });
    
      // user authentication for logged in user
      cloud.shoplive.setUserObject({
        userId: 'USER_ID'
      });
    
      // conversionConfig having products objects  
      var conversionConfig = {
        accessKey: 'YOUR_ACCESS_KEY',
        eventType: 'purchase',
        products: [
          { sku: 'sku_id1', purchaseUnitPrice: 10000, purchaseQuantity: 1 },
          { sku: 'sku_id2', purchaseUnitPrice: 15000, purchaseQuantity: 1 }
        ]
      };
      
      cloud.shoplive.sendConversionEvent(conversionConfig);
    </script>