On this page

Sales Attribution

Description

The Sales Attribution module enables store owners to track sales generated by their affiliates through the use of unique IDs in URLs. This means that store owners can accurately attribute sales to the affiliates responsible for generating them.

The orders in the backend now have this unique Affiliate ID. This makes it simple to keep track of sales attribution data, and the data can be easily exported and then filtered as needed.

In addition, the extension provides the easy setup of affiliate URLs for specific products or pages. This feature can be particularly useful for promoting some peculiar products.

Finally, the module allows for the configuration of the cookie lifespan, which determines how long the unique Affiliate ID remains active. This can be important for ensuring that affiliates receive credit for sales even if a customer does not make a purchase immediately.

Overall, the Sales Attribution module provides an efficient solution for calculating the revenue generated by the affiliates, and based on this information, the Store owner can pay commission to them.

Compatibility

The Sales Attribution module is compatible with the following Magento platforms:

Community Edition (Open Source) Enterprise Edition (Commerce) Cloud Edition
2.3.0 - 2.4.* 2.3.0 - 2.4.* 2.3.0 - 2.4.*

Installation

Installing module using zip file

  • Unzip and paste the extension file into your root Magento folder.
  • Connect to your server by SSH.
  • Go to your Magento root folder.
  • To install the extension, perform this command:
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy

Composer installation

If you haven't installed any Aitoc module before, in that case, first, you will need to add your Aitoc composer repository. Please go through the document to see how you can add the composer repository.

To install the module, you will need to run the following commands:

composer require aitoc/module-sales-attribution
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f
  • To switch the extension on/off, perform these commands:
php bin/magento module:enable Aitoc_SalesAttribution
php bin/magento module:disable Aitoc_SalesAttribution
  • To update the module, use below command:
composer update aitoc/module-sales-attribution

Building the URL

The module adds three parameters:

  • affiliate_id is an integer value representing the affiliate identity. This ID is defined outside of the module and Magento 2;
  • product_sku is the SKU of the product that is available on the website. Note that it's only the first page the customer sees on the website and they may purchase any other product - the order will still have the affiliate ID;
  • page is a URL of literally any content page on the website.

The Workflow

The store owner generates the URL with one or several parameters based on the business needs and provides it to the affiliate.

↓

The affiliate distributes this link to their network.

↓

The customer from the affiliate's network clicks this link and purchases something on the website.

↓

The affiliate_id is now available in the order details. The store owner can export these data or fetch it using REST orders endpoint.

How It Works

The structure of the URL is as follows:

The Required Part

Each URL distributed to the affiliates should have the required [site.com]/sales_attribution/sales/affiliate... part

Product SKU Parameter

https://www.site.com/sales_attribution/sales/affiliate?affiliate_id=5&product_sku=24-WG088

The SKU 24-WG088 will be matched to the corresponding product. When someone clicks this link, they are redirected to the product details page. The affiliate's ID 5 will be saved in cookie and when the customer makes the order, the order details page will have this information:

Page Parameter

https://www.example.com/sales_attribution/sales/affiliate?affiliate_id=5&page=category%2Fsub-category%2Fsomething.html
or

https://www.example.com/sales_attribution/sales/affiliate?affiliate_id=5&page=about-us.html

The page .../category/sub-category/something.html in the first example or .../about-us.html in the second will be opened. The affiliate id 5 will be saved to the cookie and when the customer makes the order, the order details page will have this information:

Note

If both product_sku and page parameters are present in the URL, it will redirect the user to a product detail page. The page parameter won't be taken into consideration.

This value will also be available when exporting order data so the store owner can easily track sales generated by the affiliate.

The store owner can control the length of time (in days) that a customer who initially came to the website through an affiliate is recognized as such. During this time interval, the affiliate_id will be recorded with the orders the customer makes. Once the period expires, the customer will be considered a regular customer and the affiliate_id will no longer be recorded.

To manage this period, go to STORES → Settings → Configuration → AITOC EXTENSIONS → Sales Attribution

The value entered in the Cookie lifespan (in days) defines the cookie expiration time. By default, it will take 14 days to expire.

The module adds affiliate_id_lifespan & affiliate_id cookie when a user redirects to your website from affiliates:

  • affiliate_id is the id of the affiliate. As a reminder, this ID is defined outside of the module and Magento 2.

  • affiliate_id_lifespan helps to identify the cookie's lifespan. If the user places the order and their cookie is old, the affiliate ID value on the order will be blank. This is managed in the configuration section. Its' value saved as UNIX timestamp }

REST API

The affiliate_id can be fetched using REST orders endpoint. The order ID is needed for this:

THANK YOU FOR CHOOSING AITOC EXTENSIONS!