Raptor tracking functions¶
Raptor connector introduces visit tracking functionality for collecting user interactions with products and content. The implementation includes product visit tracking with mapping to tracking parameters, as well as Twig functions for straightforward integration.
Raptor integration introduces two Twig functions:
ibexa_tracking_script()- allows you to embed main tracking script into the website.ibexa_tracking_track_event()- is responsible for sending event data to the service, enabling tracking of user interactions and behaviors.
Embed tracking script¶
To enable tracking, tracking script must be embedded into the website’s layout.
To embed tracking script, add the twig function ibexa_tracking_script() into the
pagelayout.html.twig:
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
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 tracking Twig function outputs different content depending on the mode:
1 2 3 4 5 6 7 | |
- server - returns HTML comments, placeholders that do not perform any action. Instead, the tracking is done server-side.
- 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:
Complex integration¶
For more complex integrations, the Ibexa Design Engine can be used to override parts or entire templates that render the tracking script.
| Template | Description | Example project path |
|---|---|---|
@ibexadesign/ibexa/tracking/script.html.twig |
Responsible for creating the window.raptor object and handling consent. Loads tracking only if consent is given and listens for the enableTracking event. |
templates/themes/standard/ibexa/tracking/script.html.twig |
@ibexadesign/ibexa/tracking/script.js.twig |
Handles the loading of the tracking JavaScript. | templates/themes/standard/ibexa/tracking/script.js.twig |
Available variables are:
- customer_id - type: string, Raptor account ID used for tracking
- script_url - type: string, URL of the tracking script, by default
//deliver.raptorstatic.com/script/raptor-3.0.min.js, configurable throughibexa.connector.raptor.tracking_script.urlSymfony Dependency Injection container parameter (not SiteAccess-aware) - has_consented - type: boolean, indicates whether the user has given consent, default value:
false(unless explicitly passed as function argument) - debug - type: boolean,
kernel.debugSymfony dependency injection container parameter, typicallytruein development environments andfalsein production
The default template defines a Twig block that includes script.js.twig.
When extending the template, this block can be overridden to customize the script’s behavior.
You can override the default templates, either individually or both at the same time.
Extension¶
It's possible to extend script.html.twig by combining the Ibexa Design Engine with standard Symfony template reference in templates/themes/standard/ibexa/tracking/script.html.twig:
1 2 3 4 | |
In most cases, the preferred approach is to do the opposite:
1 2 3 4 5 | |
Example custom integration¶
Example custom integration with TermsFeed:
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 | |
```