# SDK event tagging

In some cases you might want to add user-defined markers to events sent by our SDK to distinguish different visitor patterns and use-cases that are significant to your pricing process and strategies on QL.

A few examples can be:

  • New vs. returning users
  • Prices that belong to a particular campaign or promotion
  • Mobile vs. desktop users

To accomplish this, you can tag each event sent by our SDK with an optional array of tags, that express these patterns and use-cases.

# Example - New vs Returning visitors

In this example, we assume that you want to analyse the visit and purchase patterns of your store users and compare the sales to new visitors versus the sales to returning visitors.

To do so, you can add a tag to product and payment confirmation SDK events that mark whether a product was viewed or purchased by a new visitor or by a returning visitor.

# New visitor tagging

# SDK product event

<script>
  window.QLAsync = function(QL){
    var clientKey  = '<%= @clientKey %>',
        productId  = '<%= @productId %>',
        shelfPrice = '<%= @shelfPrice %>',
        permalink = '<%= product_url(@product.id) %>';
    QL.init(clientKey).setSDKPrefix('SDK_PREFIX'); // replace SDK_PREFIX with the correct value
    QL.sendProductEvent(productId, {
      price: parseFloat(shelfPrice, 10),
      permalink: permalink,
      tags: ['new-user']
    });
  }
</script>
<script src="//d3jdlwnuo8nsnr.cloudfront.net/sdk/v3.0/ql.js"></script>

# SDK payment confirmation event

<script>
  window.QLAsync = function(QL){
    var clientKey  = '<%= @clientKey %>',
        productId  = '<%= @productId %>',
        salePrice  = '<%= @salePrice %>';
    QL.init(clientKey).setSDKPrefix('SDK_PREFIX'); // replace SDK_PREFIX with the correct value
    QL.sendConfirmationEvent(productId, {
      price: parseFloat(salePrice, 10),
      tags: ['new-user']
    });
  }
</script>
<script src="//d3jdlwnuo8nsnr.cloudfront.net/sdk/v3.0/ql.js"></script>

# Returning visitor tagging

# SDK product event

<script>
  window.QLAsync = function(QL){
    var clientKey  = '<%= @clientKey %>',
        productId  = '<%= @productId %>',
        shelfPrice = '<%= @shelfPrice %>',
        permalink = '<%= product_url(@product.id) %>';
    QL.init(clientKey).setSDKPrefix('SDK_PREFIX'); // replace SDK_PREFIX with the correct value
    QL.sendProductEvent(productId, {
      price: parseFloat(shelfPrice, 10),
      permalink: permalink,
      tags: ['returning-user']
    });
  }
</script>
<script src="//d3jdlwnuo8nsnr.cloudfront.net/sdk/v3.0/ql.js"></script>

# SDK payment confirmation event

<script>
  window.QLAsync = function(QL){
    var clientKey  = '<%= @clientKey %>',
        productId  = '<%= @productId %>',
        salePrice  = '<%= @salePrice %>';
    QL.init(clientKey).setSDKPrefix('SDK_PREFIX'); // replace SDK_PREFIX with the correct value
    QL.sendConfirmationEvent(productId, {
      price: parseFloat(salePrice, 10),
      tags: ['returning-user']
    });
  }
</script>
<script src="//d3jdlwnuo8nsnr.cloudfront.net/sdk/v3.0/ql.js"></script>

# Integration Notes

  • Tags are flexible - You can use whatever tags you want, as long as they are passed as strings
  • Tags should be consistent - If you choose to tag an event with a certain tag, you must make sure that tag value is consistent across your SDK implementation