
Tracking – Product categorization
Discover the most-read articles
Product categorization is an advanced integration that splits your conversions by the type of product purchased. Each category gets its own Affilae key, and the script triggers the conversion matching the products actually present in the cart.
You can therefore reward a furniture sale and a book sale differently, with one commission rule per category.
What a product categorization integration does
This integration consists of:
- segmenting products by business categories (for example electronics, apparel, books);
- assigning specific Affilae KEYS to each category;
- automatically calculating amounts by category for each order;
- triggering the appropriate conversions according to the products in the cart.
Technical prerequisites
Required configuration
- An e-commerce Data Layer correctly configured.
- The category of each product in that Data Layer, for example item_category with Google Analytics 4.
- The Affilae tracking tag must be loaded on the confirmation page.
Two ways to install the integration
- GTM integration (client-side): with a Custom HTML tag.
- Custom integration (native code): direct integration in the confirmation page code.
Example code
Below is an example for two categories, plus a default key for all other products. It reads the category of each product in the GA4 Data Layer and sends one conversion per key, with the same order number.
Adapting the code to your shop
- Create in GTM the data layer variables dl_ecommerce.items, dl_ecommerce.transaction_id and dl_ecommerce.coupon (paths ecommerce.items, ecommerce.transaction_id, ecommerce.coupon).
- List your categories in keysByCategory, written exactly as in your Data Layer: the comparison is case- and accent-sensitive.
- Map each category to the key of its rule, in the Rule ID-Program ID format, as shown in the Tracking tab.
- Choose defaultKey: the key of a rule covering all other products, or
''if you do not pay commission on other categories. - Check the amount: each conversion receives the sum of price × quantity of its products. The price field of your Data Layer must exclude tax; a discount applied to the whole order is not deducted.
- Replace EUR with a currency of your rules: a currency not listed in the Rule Currencies of the rule gets the conversion refused.
- If your Data Layer stores the category elsewhere (for example item_category2), adapt the line reading item_category.
Where to find your keys and your IDs
- In the sidebar, click Programs, then your program name.
- Click Configuration.
- Open the Tracking tab.
- Expand the Integration via an Affilae plugin section: it shows the Program ID. Pick the rule in the list: the section shows its Rule ID, its Currency and its Key.

Points of attention
- Check your DataLayer structure before installing the tag.
- Test with real orders.
- Verify calculated amounts and the various category triggers.
- A product whose category is not listed goes to defaultKey, or triggers no conversion if defaultKey is empty.
Related articles
- Testing click and conversion tracking
- Integrating scripts via Google Tag Manager
- Frequently asked questions on technical integration
- Product feeds: what they are for and what your file must contain
- Affilae tracking fundamentals
Frequently asked questions
Check the Program ID. That is the value tying the click script to your program. You find it in Programs, your program, Configuration, Tracking tab, Integration via an Affilae plugin section.
Check three things, in this order. The variables of your dataLayer, the category names you listed in the code, and the Affilae keys used for each category. A single wrong value among those three is enough to make the conversion disappear or attach it to the wrong rule, with no error message.
In your program configuration, Tracking tab, Integration via an Affilae plugin section. It shows the Program ID, the Rule ID, the Currency and the Key. The key has the Rule ID-Program ID form.
Yes. In Affilae, an event, here the sale of a product in a given category, corresponds to a commission rule, and therefore to a key. You create as many rules as there are categories to track, plus one rule for defaultKey if you pay commission on other products.
It is sent with defaultKey. If defaultKey is empty, no conversion is triggered for that product.
No, testing is mandatory before going live. Place a real order per category, then check the calculated amounts and the trigger of each conversion. If in doubt, contact Affilae support with the details of your configurations.