Skip to content

Raptor tracking functions

Raptor tracking functions introduce 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:

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 section of your base layout template, for example, pagelayout.html.twig:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
{# templates/pagelayout.html.twig #}
<!DOCTYPE html>
<html>
<head>
    {# ... other head content ... #}

    {# Initialize Raptor tracking - must be called before any tracking events #}
    {{ ibexa_tracking_script() }}
</head>
<body>
    {# ... page content ... #}
</body>
</html>
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## 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 function outputs different content depending on the mode:

``` yaml
# Server-side tracking
connector_raptor:
    tracking_type: 'server'  # Returns HTML comments

# Client-side tracking
connector_raptor:
    tracking_type: 'client'  # Returns <script> tags
  • server - returns HTML comments, placeholders that do not perform any action. Instead, the tracking is done server-side.
  • client - returns script tags 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: