Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions docs/recommendations/raptor_integration/hybrid_tracking.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
description: Enable hybrid tracking to avoid ad blockers and proxy events through your server.
month_change: true
---

# Raptor hybrid tracking

Hybrid tracking mode is an additional tracking mode available alongside [`client` and `server`](tracking_functions.md).
In hybrid mode, the bundle includes a client side shim that captures Raptor tracking events and sends them to a same-origin endpoint instead of communicating directly with Raptor SaaS.
The server enriches each event with identifiers resolved from request cookies (`cookieId`, `sessionId`, and `userId`) and forwards it to Raptor asynchronously through [Messenger](background_tasks.md).
Since the browser never connects to the Raptor domain, ad blockers cannot block the requests.

## Hybrid vs server or client side tracking

Both `server` and `hybrid` tracking modes deliver pageviews and events server side, so tracking requests are not affected by ad blockers.

Check failure on line 15 in docs/recommendations/raptor_integration/hybrid_tracking.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/recommendations/raptor_integration/hybrid_tracking.md#L15

[Ibexa.Spellcheck] Did you really mean 'pageviews'?
Raw output
{"message": "[Ibexa.Spellcheck] Did you really mean 'pageviews'?", "location": {"path": "docs/recommendations/raptor_integration/hybrid_tracking.md", "range": {"start": {"line": 15, "column": 51}}}, "severity": "ERROR"}
The main difference is that `hybrid` mode loads a local, first-party tracking JavaScript (`raptor-proxy.js`) provided by the DXP instance, instead of the Raptor SaaS JavaScript.
The Raptor script itself (`//deliver.raptorstatic.com/script/raptor-3.0.min.js`) is loaded only in `client` mode.

Check notice on line 17 in docs/recommendations/raptor_integration/hybrid_tracking.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/recommendations/raptor_integration/hybrid_tracking.md#L17

[Ibexa.Passive] Try to avoid passive tense, when possible.
Raw output
{"message": "[Ibexa.Passive] Try to avoid passive tense, when possible.", "location": {"path": "docs/recommendations/raptor_integration/hybrid_tracking.md", "range": {"start": {"line": 17, "column": 82}}}, "severity": "INFO"}

The browser script only forwards captured tracking events to the same-origin proxy endpoint on your DXP instance. First-party visitor cookies are created and refreshed server side, which is what helps them survive Safari ITP.

Check notice on line 19 in docs/recommendations/raptor_integration/hybrid_tracking.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/recommendations/raptor_integration/hybrid_tracking.md#L19

[Ibexa.Passive] Try to avoid passive tense, when possible.
Raw output
{"message": "[Ibexa.Passive] Try to avoid passive tense, when possible.", "location": {"path": "docs/recommendations/raptor_integration/hybrid_tracking.md", "range": {"start": {"line": 19, "column": 143}}}, "severity": "INFO"}
Event tracking still happens on the server, so ad blockers cannot block it.

The main advantage of `hybrid` mode over `server` mode is its ability to capture client side tracking events.
Visitor cookies are also refreshed more frequently than in `server` mode.

Check the table below to compare the behavior of different tracking modes:

|Tracking type|Browser script|Event delivery|Works with ad blockers|Cookie refresh |
|-------------|--------------|--------------|----------------------|-------------------------------------|
|client |yes |Browser |no |yes |
|server |no |Server |yes |yes (server side, on full page loads)|
|hybrid |yes |Server |yes |yes |

## Hybrid tracking flow

When hybrid tracking is enabled, `TrackingScriptExtension` renders the proxy bootstrap template and loads the `raptor-proxy.js` shim, which replaces the `window.raptor.push` and drains the initial event queue.

Check notice on line 35 in docs/recommendations/raptor_integration/hybrid_tracking.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/recommendations/raptor_integration/hybrid_tracking.md#L35

[Ibexa.Passive] Try to avoid passive tense, when possible.
Raw output
{"message": "[Ibexa.Passive] Try to avoid passive tense, when possible.", "location": {"path": "docs/recommendations/raptor_integration/hybrid_tracking.md", "range": {"start": {"line": 35, "column": 22}}}, "severity": "INFO"}
The shim sends events to the configured proxy endpoint, by default, `/raptor/track`.
Each event is sent in a separate request using a batch-compatible format.

Check notice on line 37 in docs/recommendations/raptor_integration/hybrid_tracking.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/recommendations/raptor_integration/hybrid_tracking.md#L37

[Ibexa.Passive] Try to avoid passive tense, when possible.
Raw output
{"message": "[Ibexa.Passive] Try to avoid passive tense, when possible.", "location": {"path": "docs/recommendations/raptor_integration/hybrid_tracking.md", "range": {"start": {"line": 37, "column": 12}}}, "severity": "INFO"}

Check notice on line 37 in docs/recommendations/raptor_integration/hybrid_tracking.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/recommendations/raptor_integration/hybrid_tracking.md#L37

[Ibexa.ByUsing] Prefer 'by using' or 'with' to plain 'using'.
Raw output
{"message": "[Ibexa.ByUsing] Prefer 'by using' or 'with' to plain 'using'.", "location": {"path": "docs/recommendations/raptor_integration/hybrid_tracking.md", "range": {"start": {"line": 37, "column": 34}}}, "severity": "INFO"}
The `TrackingProxyController::track` controller validates the `EventPayloadParser` payload, enriches each event with identifiers resolved from cookies, and dispatches one `TrackProxiedEventMessage` for every event.
Messages are then processed asynchronously via Messenger and `TrackProxiedEventMessageHandler` ultimately forwards them to Raptor through `TrackingService::trackRawParameters`.

### Hybrid tracking configuration

To configure the Raptor hybrid tracking, use the `ibexa.system.<scope>.connector_raptor` configuration key in the `config/packages/ibexa_connector_raptor.yaml` file:

``` yaml
ibexa_connector_raptor:
hybrid_tracking_proxy_path: '/track'

ibexa:
system:
default:
connector_raptor:
enabled: true
customer_id: '<id>'
tracking_type: hybrid
```

### Routing import

Hybrid tracking requires routing import.
It means that the proxy endpoint route must be imported in the project, for example in the `config/routes.yaml` file:

Check notice on line 61 in docs/recommendations/raptor_integration/hybrid_tracking.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/recommendations/raptor_integration/hybrid_tracking.md#L61

[Ibexa.Passive] Try to avoid passive tense, when possible.
Raw output
{"message": "[Ibexa.Passive] Try to avoid passive tense, when possible.", "location": {"path": "docs/recommendations/raptor_integration/hybrid_tracking.md", "range": {"start": {"line": 61, "column": 45}}}, "severity": "INFO"}

``` yaml
ibexa.connector_raptor:
resource: '@IbexaConnectorRaptorBundle/Resources/config/routing.yaml'
```

This import is required only in `hybrid` mode.

Check notice on line 68 in docs/recommendations/raptor_integration/hybrid_tracking.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/recommendations/raptor_integration/hybrid_tracking.md#L68

[Ibexa.Passive] Try to avoid passive tense, when possible.
Raw output
{"message": "[Ibexa.Passive] Try to avoid passive tense, when possible.", "location": {"path": "docs/recommendations/raptor_integration/hybrid_tracking.md", "range": {"start": {"line": 68, "column": 13}}}, "severity": "INFO"}
Without it, the proxy endpoint returns 404 responses and tracking events are not processed.

### Proxy path configuration

You can configure the proxy endpoint path globally.
By default, it's set to `/raptor/track`.
The client side shim sends tracking events to this same-origin endpoint, which forwards them to Raptor asynchronously.

``` yaml
ibexa_connector_raptor:
hybrid_tracking_proxy_path: '/track'
```

!!! note

The path must start with a `/` symbol and cannot overlap with any existing routes.
The route is generated from this value, so updating it automatically updates the route as well.

Check notice on line 85 in docs/recommendations/raptor_integration/hybrid_tracking.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/recommendations/raptor_integration/hybrid_tracking.md#L85

[Ibexa.Passive] Try to avoid passive tense, when possible.
Raw output
{"message": "[Ibexa.Passive] Try to avoid passive tense, when possible.", "location": {"path": "docs/recommendations/raptor_integration/hybrid_tracking.md", "range": {"start": {"line": 85, "column": 14}}}, "severity": "INFO"}
You don't need to modify the routing import.

After changing the configuration, clear the application cache:

``` bash
php bin/console cache:clear
```

Verify that the route has been registered correctly.

Check notice on line 94 in docs/recommendations/raptor_integration/hybrid_tracking.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/recommendations/raptor_integration/hybrid_tracking.md#L94

[Ibexa.Passive] Try to avoid passive tense, when possible.
Raw output
{"message": "[Ibexa.Passive] Try to avoid passive tense, when possible.", "location": {"path": "docs/recommendations/raptor_integration/hybrid_tracking.md", "range": {"start": {"line": 94, "column": 27}}}, "severity": "INFO"}
To do it, run the following command:

``` bash
php bin/console debug:router | grep raptor
```

### Template usage

By default, the tracking script waits for user consent before sending tracking events.
Consent can be provided either by rendering the script with `ibexa_tracking_script` (`has_consented` = `true`) or by triggering the `enableTracking` JavaScript event.

Check notice on line 104 in docs/recommendations/raptor_integration/hybrid_tracking.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/recommendations/raptor_integration/hybrid_tracking.md#L104

[Ibexa.Passive] Try to avoid passive tense, when possible.
Raw output
{"message": "[Ibexa.Passive] Try to avoid passive tense, when possible.", "location": {"path": "docs/recommendations/raptor_integration/hybrid_tracking.md", "range": {"start": {"line": 104, "column": 13}}}, "severity": "INFO"}
The same template syntax is used across all tracking modes, so changing `tracking_type` does not require any template changes.

Check notice on line 105 in docs/recommendations/raptor_integration/hybrid_tracking.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/recommendations/raptor_integration/hybrid_tracking.md#L105

[Ibexa.Passive] Try to avoid passive tense, when possible.
Raw output
{"message": "[Ibexa.Passive] Try to avoid passive tense, when possible.", "location": {"path": "docs/recommendations/raptor_integration/hybrid_tracking.md", "range": {"start": {"line": 105, "column": 26}}}, "severity": "INFO"}

The Twig API remains identical regardless of the configured tracking mode:

``` html+twig
{{ ibexa_tracking_script() }}
{{ ibexa_tracking_track_event('visit', product) }}
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ nav:
- Raptor connector guide: recommendations/raptor_integration/raptor_connector_guide.md
- Installation and configuration: recommendations/raptor_integration/connector_installation_configuration.md
- Tracking functions: recommendations/raptor_integration/tracking_functions.md
- Hybrid tracking: recommendations/raptor_integration/hybrid_tracking.md
- Tracking with PHP API: recommendations/raptor_integration/tracking_php_api.md
- Recommendations blocks: recommendations/raptor_integration/recommendation_blocks.md
- Custom recommendation rendering: recommendations/raptor_integration/custom_recommendation_rendering.md
Expand Down
Loading