Affiliate Tracking

Overview

  • Bigfish has a feature called Pixel Tracking.
  • Admin arrow Tools options
  • Pixel Tracking provides a powerful way to include functions throughout the site that can be used for various tasks.
  • The most common is probably tracking affiliate information.

Business Scenarios

  • Simple Scenario:
    • A customer may be browsing the web, sees a banner ad, clicks on the ad.
    • If that customer purchases a product then the “affiliate” gets credit for that sale and is paid a commission.
    • This scenario is easily solved since the customer originated their visit with an URL of something like “?affiliate=acme”.
    • This is simply tracked throughout the visit, in the session, and credit given on Order Confirmation.
  • Typical Scenario:
    • It is more typical that an Affiliate is to given credit if the customer makes a purchase a certain number of days after seeing the banner ad.
    • So, the customer is browsing the web, sees a banner ad, clicks on the ad.
    • They browse your site, but not complete the purchase.
    • Some days later they return to your site directly (not via a banner link) and complete the purchase.
    • The Affiliate may still be due a commission since the visit was initiated by their banner efforts.
  • Additional Nuance
    • In many cases you may have multiple Affiliate programs running at the same time.
    • You only want to pay commission to one Affiliate.
    • So, if both Affiliates prompt the same customer to enter your site, the solution provided below will give credit to the last affiliate.
  • The client.properties file contains many of the high-level configuration options that the underlying platform OFBiz requires:
    • The client-deployment.properties files is a BigFish configuration file that consolidates the various OFBiz properties.
    • To build / admin-module / restart apache.

Identifying an Affiliate and tracking in a cookie

  • First, create a Pixel Tracking as follows:
    • Name: AFFILIATE_TRACKING
    • Scope: ALL_EXCEPT_ORDER_CONFIRM
    • Script:
    • 
      <script type="text/javascript">
      // store cookie value with optional details as needed
      function setPixelCookie (name, value, expires, path, domain, secure) {
          document.cookie = name + "=" + escape (value) +
              ((expires) ? "; expires=" + expires : "") +
              ((path) ? "; path=" + path : "") +
              ((domain) ? "; domain=" + domain : "") +
              ((secure) ? "; secure" : "");
      }
      </script>
      
      <script type="text/javascript">
         <#if parameters.affiliate?exists && parameters.affiliate?has_content>
              setPixelCookie('AFFILIATE_TRACKING','${parameters.affiliate}');
        </#if>
      </script>
      
      
    • Notes:
      • The name of the cookie (AFFILIATE_TRACKING) is entirely up to you.
      • This script will capture the value ACME of from the URL suffix “?affiliate=ACME”.

Pixel Tracking is stored in memory cache.
Whenever you make modifications to scripts the cache will need to be reset.

Admin arrow Tools arrow Clear Bigfish Cache.

Using the cookie value to give credit to an Affiliate

  • Create an additional Pixel Tracking as follows:
    • Name: AFFILIATE_COMMISSION
    • Scope: ORDER_CONFIRM
    • Script:

<script type="text/javascript">
// primary function to retrieve cookie by name
function getPixelCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) {
            return getPixelCookieVal(j);
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break; 
    }
    return null;
}
// utility function called by getCookie()
function getPixelCookieVal(offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1) {
        endstr = document.cookie.length;
    }
    return unescape(document.cookie.substring(offset, endstr));
}
</script>


<script type="text/javascript">
   // Get the value from the Cookie AFFILIATE_TRACKING
   // If it exists and has not expired then
   //     depending on which Affiliate is identified generate
   //         an appropriate script
  
   var AFFILIATE = getPixelCookie('AFFILIATE_TRACKING');
   if (AFFILIATE)
   {
      if (AFFILIATE.toUpperCase() == 'ACME')
     {
        var _affiliate = [];
        _affiliate.push(['ACME_ORDER_ID', '${ORDER_ID!}']);
        _affiliate.push(['ACME_ORDER_ITEMS_QTY', '${ORDER_ITEMS_QTY!}']);
        _affiliate.push(['ACME_ORDER_ITEMS_MONEY', '${ORDER_ITEMS_MONEY!}']);
        _affiliate.push(['ACME_ORDER_TOTAL_PROMO', '${ORDER_TOTAL_PROMO!}']);
        _affiliate.push(['ACME_ORDER_TOTAL_SHIP', '${ORDER_TOTAL_SHIP!}']);
        _affiliate.push(['ACME_ORDER_TOTAL_TAX', '${ORDER_TOTAL_TAX!}']);
       _affiliate.push(['ACME_ORDER_TOTAL_MONEY', '${ORDER_TOTAL_MONEY!}']);
     }
  
     if (AFFILIATE.toUpperCase() == ‘XYZ’)
     {
        var _affiliate = [];
        _affiliate.push(['ABC_ORDER_ID', '${ORDER_ID!}']);
        _affiliate.push(['ABC_ORDER_ITEMS_QTY', '${ORDER_ITEMS_QTY!}']);
        _affiliate.push(['ABC_ORDER_ITEMS_MONEY', '${ORDER_ITEMS_MONEY!}']);
        _affiliate.push(['ABC_ORDER_TOTAL_PROMO', '${ORDER_TOTAL_PROMO!}']);
        _affiliate.push(['ABC_ORDER_TOTAL_SHIP', '${ORDER_TOTAL_SHIP!}']);
        _affiliate.push(['ABC_ORDER_TOTAL_TAX', '${ORDER_TOTAL_TAX!}']);
        _affiliate.push(['ABC_ORDER_TOTAL_MONEY', '${ORDER_TOTAL_MONEY!}']);
     }
   }
</script>

Pixel Tracking is stored in memory cache.
Whenever you make modifications to scripts the cache will need to be reset.

Admin arrow Tools arrow Clear Bigfish Cache.

Tagging an Order with the Affiliate

Verifying your commission charges

  • In most cases you will want to verify the Invoice received from the Affiliate.
  • This process describes how to tag the Order with the affiliate value.
    • In the above example, this would be either ACME or ABC.

Bigfish Configuration

  • Review the parameter CHECKOUT_CONFIRM_GET_COOKIE
    • Description: A comma separated list of Cookies that should be read for possible content. The Order Confirmation will use the content of each cookie, if it exists, to store additional attributes for the Order. Typically used for Affiliate Tracking.
  • Using the above example the parameter CHECKOUT_CONFIRM_GET_COOKIE should be set to AFFILIATE_TRACKING.
  • This means that on Order Confirmation the cookie AFFILIATE_TRACKING will be reviewed If there is a value then this value will be tagged as a value pair on the Order.
  • Technical Note:
    • The value is stored on the ORDER_ATTRIBUTE entity.
    • ATTR_NAME is the name of the Cookie, in our example AFFILIATE_TRACKING.
    • ATTR_VALUE is the actual value, in our example ACME.
Back to Top

Built by Solveda