Using the API to create conversions

Affiliate Tracker includes a very simple, but powerful API, that you can use to track virtually any kind of activity that you want to monitorize from your affiliates.

We provide handy plugins that integrate with extensions for sales tracking (VirtueMart, PayPlans...), but you maybe interested in tracking other particular actions that are not included in our plugins. For this reason we've included an API so you can call it directly from your component.

In order to use it, you need to place the code we've provided wherever you want that action to be tracked, in any of your compoents.

When the action is triggered, the system will automatically identify if the user came originally from an affiliate link, and if that's the case, it will log the new conversion in Affilate Tracker's conversion log.

This is the code needed to create a new conversion from your own component:

$conversion_data = array(
    "name" => "Custom Order",
    "component" => "com_yourcomponent",
    "extended_name" => "The item name",
    "type" => 1,
    "value" => 100 ,
    "reference_id" => 234,
    "approved" => 1,
);
 
require_once(JPATH_SITE.DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'com_affiliatetracker'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'helpers.php');
AffiliateHelper::create_conversion($conversion_data, $user_id);

Let's explain the available fields one by one:

  1. name: (required) The name of the conversion.
  2. component: The component name. E.g. com_yourcomponent
  3. extended_name: A specific item name for the conversion.
  4. type: (required) 1 in most cases. It is used to identify different types of commissions for the same component.
  5. value: (required) The monetary value of the conversion.
  6. reference_id: A reference to identify the conversions created with this API call.
  7. approved: (required) A boolean indicating if the conversion is automatically approved or needs approval.
  8. atid: The affiliate id to whom the conversion will be created. Leave it empty to let the system find it.