Working with multiple product groups

Product groups can be used for Offers that are tracking sales with a percentage payout. They allow you to use different payouts for different product categories. If you are, for example, selling smartphones and smartphone covers, the margin on the covers is so much higher that you want to give a higher payout for those.

To implement multiple product groups, you first need to create the product groups and then modify your tracking implementation.

1. Create product groups

You can create product groups in the tracking tab when creating or editing an Offer. Every product group has a unique ID that can be found right next to the name:

2. Modify tracking

The product group ID should be placed as value of the event_sid  parameter in the tracking pixel. As a result you have a separate tracking pixel for each product group. If an order consists of products belonging to different product groups, one pixel for every product group needs to be fired. This means the products that are part of the order should be grouped by product group.

The best way to group the products is to create a loop that runs through all the products of the order and checks their category. The specific implementation depends on the programming language of your Offer’s website, but below is an example implementation in PHP.

<?php
/* Configuration */
$offer_sid = 'OFFER_ID';
$type = 'TRANSACTION_TYPE';
$order_id = 'ORDER_ID'

/* Create an array that will contain the transaction amount for each product group */
$amountsPerProductGroup = array();

/* Browse through every product of the order */
foreach ($products as $product) {
    /* Determine the product group for each product or fallback to the default product group */
    switch($product['productCategory']) {
        case 'category1':
            $productID = 'PRODUCT_ID';
            break;
        case 'category2':
            $productID = 'PRODUCT_ID';
            break;
        default:
            $productID = 'PRODUCT_ID';
            break;
    }

    /* Add up the transaction amount for each product within a product group */
    if (!array_key_exists($productID, $amountsPerProductGroup)) {
        $amountsPerProductGroup[$productID] = 0;
    }
    $amountsPerProductGroup[$productID] += $product['productAmount'];
}

/* Print image tag for every product group */
foreach ($amountsPerProductGroup as $productID => $amount) {
    echo "<img src="//p.trackmytarget.com/?offer_sid={$offer_sid}&event_sid={$productID}&type={$type}&id={$order_id}&amount={$amount}" alt="" />";
}

?>
Boost your affiliate program

Download our free whitepaper for insights into 2020’s top affiliate marketing trend: self-service affiliate programs

© 2020 Target Circle AS | Terms & Privacy | Cookie preferences | Email

Learn the 2020’s Top Affiliate Marketing Trends