Raptor tracking function¶
Raptor tracking function introduces visit tracking functionality for collecting user interactions with products and content. The implementation includes product visit tracking with mapping to tracking parameters and automatic price formatting, as well as Twig functions for straightforward integration. It supports multi-currency setups with automatic decimal formatting (0, 2, or 3 decimals) based on configuration, and integrates with taxonomy to extract and format category paths for product categorization.
Initialize Raptor tracking script¶
First, initialize the ibexa_tracking_script() tracking script in your base layout template, typically within the
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Tracking parameters¶
Tracking is handled through twig function that accept following parameters:
1 2 3 4 5 6 | |
- eventType - type: string, defines the type of tracking event to be sent, for example,
visit,contentvisit,buy,basket,itemclick - data (optional) - type: mixed, defines the primary object associated with the event, such as a Product or Content, can be null if not required
- context (optional)- type: array, additional event data, such as quantity, basket details, or custom parameters
- template (optional) - type: string, path to a custom Twig template used to render the tracking event, allows overriding the default tracking output
context parameter - example usage¶
You can use context parameter to add additional data.
During tracking, for products assigned to multiple categories, the system uses the first category.
In this case, context parameter allows to override the product category by passing a category identifier:
1 2 3 4 5 6 7 8 9 10 11 | |
Tracking modes¶
Tracking user interactions can be implemented on the client-side or the server-side.
Each approach differs in where events are captured and how they are sent to the tracking backend.
The ibexa_tracking_track_event() function works based on tracking_type configuration.
The tracking function outputs different content depending on the mode:
1 2 3 4 5 6 7 | |
- server - returns HTML comments, leaving placeholders without running JavaScript.
- client - returns
scripttags to load the tracking script in the browser.
You can switch tracking mode anytime by changing the tracking_type parameter.
For more information on Tracking modes, see Raptor documentation:
Advanced usage – direct interaction with the service¶
EventMapper method¶
The recommended method, providing full control over event tracking, is EventMapper method.
It allows to interact directly with the service, supporting advanced configuration beyond what the Page Builder offers.
Check the following example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
Manual EventData creation¶
Manual creation of EventData allows precise control over the events sent to the service. It enables to define custom event parameters, track specific user interactions, and tailor data collection to advanced use cases.
Check the following example:
1 2 3 4 5 6 7 8 9 10 11 | |
Example - event subscriber¶
If you need to track events automatically based on application events, you can use Event Subscriber. It reacts to specific events in the application and triggers tracking logic without the need to add it manually in templates.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |
Tracking events¶
The following events are supported and can be triggered from Twig templates:
Product Visit event¶
This event tracks product page visits by users. It's the most common e-commerce tracking event used to capture product views for analytics, recommendation models, and user behavior processing.
Required data:
- Product object - defines the product being tracked. It implements
ProductInterfaceso the system can read its information (for example, ID, price, category).
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Content Visit event¶
This event tracks content page visits by users. It can used to check content views for analytics, personalization, and user behavior tracking.
- Content object - defines the content being tracked.
Basket event¶
This event tracks when a product is added to the shopping basket. It catches user interest and helps with conversion tracking and product recommendations.
Required data:
- Product object - defines the product being added to the basket.
- Context array with basket information - provides optional data about the basket, like quantity or basket ID, to provide context for the event.
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | |
Simplified example with Twig filter:
1 2 3 4 5 6 7 8 | |
Custom Templates¶
You can override the default tracking templates by providing a custom template path:
1 2 3 4 5 6 | |