Examples

Tracking a specific commission type

If you have added multiple commission types for your program, you can specify which commission type applies for the conversion you are tracking.

<script src="https://script.tapfiliate.com/tapfiliate.js" type="text/javascript" async></script>
<script type="text/javascript">
  (function(t,a,p){t.TapfiliateObject=a;t[a]=t[a]||function(){
  (t[a].q=t[a].q||[]).push(arguments)}})(window,'tap');

  tap('create', 'YOUR ACCOUNT ID');
  tap('conversion', 'UNIQUE CONVERSION ID', CONVERSION AMOUNT, {}, 'COMMISSION-TYPE-IDENTIFIER');
</script>
  • COMMISSION-TYPE-IDENTIFIER is the identifier that was added when the commission was created. Commissions are created per program, from the ‘commission structure’ option in the program settings.

Tracking multiple commissions

When you need to track multiple commissions for a single conversion, conversionMulti can be used. This is useful when the commission you give, varies per product or category for example.

The usual approach is to loop over the line items in your order to build up an array of commissions.

<script src="https://script.tapfiliate.com/tapfiliate.js" type="text/javascript" async></script>
<script type="text/javascript">
  (function(t,a,p){t.TapfiliateObject=a;t[a]=t[a]||function(){
  (t[a].q=t[a].q||[]).push(arguments)}})(window,'tap');

  tap('create', 'YOUR ACCOUNT ID');

  var myOrder = {}; // get from your server

  var commissions = myOrder.lineItems.map(function(lineItem) {
    return {
      sub_amount: lineItem.subTotal,
      commission_type: lineItem.product.sku
    };
  })

  tap('conversionMulti', 'UNIQUE CONVERSION ID', {}, commissions);
</script>
                    

Note: Be aware that tracking different commissions for different products/categories might imply creating separate ‘thank you’ pages per product/category, each with the specific version of the tracking code.

Tracking to a specific program group

If you want to use Tapfiliate with multiple sites, you will need to create a program group for each site you will integrate Tapfiliate into and assign your program to that group. Next, you will need to add the program group identifier to your tracking code:

<script src="https://script.tapfiliate.com/tapfiliate.js" type="text/javascript" async></script>
<script type="text/javascript">
  (function(t,a,p){t.TapfiliateObject=a;t[a]=t[a]||function(){
  (t[a].q=t[a].q||[]).push(arguments)}})(window,'tap');

  tap('create', 'YOUR ACCOUNT ID');
  tap('conversion', 'UNIQUE CONVERSION ID', CONVERSION AMOUNT, {program_group: 'my-group'});
</script>

Adding Meta Data to a conversion

If you want to store additional data alongside a conversion, e.g. a lead’s name and email, you can do so by adding a meta object within the options object in the conversion code:

<script src="https://script.tapfiliate.com/tapfiliate.js" type="text/javascript" async></script>
<script type="text/javascript">
  (function(t,a,p){t.TapfiliateObject=a;t[a]=t[a]||function(){
  (t[a].q=t[a].q||[]).push(arguments)}})(window,'tap');

  tap('create', 'YOUR ACCOUNT ID');

  var metaData = {
      email: "chuck@norris.com",
      foo: "bar",
  };

  tap('conversion', 'UNIQUE CONVERSION ID', CONVERSION AMOUNT, {meta_data: metaData});
</script>

Useful when visitors land on a specific subdomain and later convert on a different subdomain. In this case the cookie is set on the initial subdomain and is thus not visible from the second subdomain, and thus tracking will be lost. This can be fixed by explicitly setting the cookie on your main domain.:

<script src="https://script.tapfiliate.com/tapfiliate.js" type="text/javascript" async></script>
<script type="text/javascript">
  (function(t,a,p){t.TapfiliateObject=a;t[a]=t[a]||function(){
  (t[a].q=t[a].q||[]).push(arguments)}})(window,'tap');

  tap('create', 'YOUR ACCOUNT ID');
  tap('detect', {cookie_domain: 'your-main-domain.com'});
</script>