Skip to content
Open
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,71 @@

- **eventType** - type: string, defines the type of tracking event to be sent, for example, `visit`, `contentvisit`, `buy`, `basket`, `itemclick`. For more information, see [Tracking events for recommendations](https://content.raptorservices.com/help-center/tracking-events-parameters-reference).
- **data** (optional) - type: mixed, accepts the primary object associated with the event, such as a Product or Content, can be null if not required. For more information, see [tracking event examples](#tracking-events).
- **context** (optional)- type: array, additional event data, such as quantity, basket details, or custom parameters. For more information, see [example usage](#context-parameter-example-usage).
- **context** (optional)- type: array, additional event data, such as quantity, basket details, [website ID](#websiteid-parameter), or custom parameters. For more information, see [example usage](#context-parameter-example-usage).
- **template** (optional) - type: string, path to a custom Twig template used to render the tracking event, allows overriding the default tracking output.

### `websiteId` parameter

The `websiteId` (`p7`) parameter for [Raptor tracking](https://content.raptorservices.com/help-center/introduction-to-tracking-documentation) can be optionally provided as a **context** to `ibexa_tracking_track_event()` function.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The `websiteId` (`p7`) parameter for [Raptor tracking](https://content.raptorservices.com/help-center/introduction-to-tracking-documentation) can be optionally provided as a **context** to `ibexa_tracking_track_event()` function.
The `websiteId`, also known as a **Login ID**, (`p7`) parameter for [Raptor tracking](https://content.raptorservices.com/help-center/introduction-to-tracking-documentation) can be optionally provided as a **context** to `ibexa_tracking_track_event()` function.

Let's introduce this alternative name in the introduction of this parameter.

BTW, Raptor doc calls it "User ID"? https://content.raptorservices.com/help-center/user-tracking-understanding-soft-ids-hard-ids-raptor-identity-matching#:~:text=IDs%3A-,UserId%20%28Website%20ID

The explanation from the Raptor doc:internal site ID for logged‑in users sounds useful


Example:

``` html+twig
{{ ibexa_tracking_track_event('visit', product, {
websiteId: 'my-id'
Comment thread
julitafalcondusza marked this conversation as resolved.
Outdated
}) }}
```
Comment on lines +84 to +90

@mnocon mnocon Jul 10, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's recommended to to this, as it's not better from the default implementation.

We need to describe a business cases here, for example (sentences are a draft):

Suggested change
Example:
``` html+twig
{{ ibexa_tracking_track_event('visit', product, {
websiteId: 'ibexa_user_get_current().login'
}) }}
```
When storing customer data in an external Customer Relationship Management (CRM) system, set the `websiteId` to an identifier of the customer stored there.
The following example shows how you pass that value, assuming a custom Twig function `get_custom_crm_identifier` integrating with that CRM exists:
``` html+twig
{{ ibexa_tracking_track_event('visit', product, {
websiteId: get_custom_crm_identifier(ibexa_user_get_current().login)
}) }}

This one doesn't handle the anonymous user, which I guess would be a bug - so we need to verify this if this should be expanded even further


The website ID, also known as a **Login ID**, is available for logged-in users.
It serves as a persistent, cross-device identifier.
Both the User ID and the Cookie ID can be used to personalize website modules.

Check notice on line 94 in docs/templating/twig_function_reference/recommendations_twig_functions.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/templating/twig_function_reference/recommendations_twig_functions.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/templating/twig_function_reference/recommendations_twig_functions.md", "range": {"start": {"line": 94, "column": 40}}}, "severity": "INFO"}
Comment on lines +92 to +94

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"is available" is confusing here, makes it sounds as if it's calculated for users when they log in.

Maybe:

Suggested change
The website ID, also known as a **Login ID**, is available for logged-in users.
It serves as a persistent, cross-device identifier.
Both the User ID and the Cookie ID can be used to personalize website modules.
Set the `websiteId` parameter for logged-id users, for which you have data uniquely identifying them.
The value of this parameter serves as a persistent, cross-device identifier of the user.
Example values are User ID or the Cookie ID.


The value of `websiteId` parameter is resolved in the following order:

Check notice on line 96 in docs/templating/twig_function_reference/recommendations_twig_functions.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/templating/twig_function_reference/recommendations_twig_functions.md#L96

[Ibexa.Passive] Try to avoid passive tense, when possible.
Raw output
{"message": "[Ibexa.Passive] Try to avoid passive tense, when possible.", "location": {"path": "docs/templating/twig_function_reference/recommendations_twig_functions.md", "range": {"start": {"line": 96, "column": 36}}}, "severity": "INFO"}

1. Explicit `websiteId` passed in the `ibexa_tracking_track_event()` context.
2. Custom `WebsiteIdContextProviderInterface` implementations (the first one returning a non-null value wins).
Comment thread
julitafalcondusza marked this conversation as resolved.
Outdated
3. The built-in provider, which uses the logged-in user's identifier (`ruid`).

If no value is resolved, the event is sent without the `p7` parameter.

Check notice on line 102 in docs/templating/twig_function_reference/recommendations_twig_functions.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/templating/twig_function_reference/recommendations_twig_functions.md#L102

[Ibexa.Passive] Try to avoid passive tense, when possible.
Raw output
{"message": "[Ibexa.Passive] Try to avoid passive tense, when possible.", "location": {"path": "docs/templating/twig_function_reference/recommendations_twig_functions.md", "range": {"start": {"line": 102, "column": 13}}}, "severity": "INFO"}

Check notice on line 102 in docs/templating/twig_function_reference/recommendations_twig_functions.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/templating/twig_function_reference/recommendations_twig_functions.md#L102

[Ibexa.Passive] Try to avoid passive tense, when possible.
Raw output
{"message": "[Ibexa.Passive] Try to avoid passive tense, when possible.", "location": {"path": "docs/templating/twig_function_reference/recommendations_twig_functions.md", "range": {"start": {"line": 102, "column": 36}}}, "severity": "INFO"}

To resolve `websiteId` on the project level, implement the interface as follows:

``` php
<?php

declare(strict_types=1);

namespace App\Tracking;

use Ibexa\Contracts\ConnectorRaptor\Tracking\ContextProvider\WebsiteIdContextProviderInterface;

final class MyWebsiteIdProvider implements WebsiteIdContextProviderInterface
{
public function getWebsiteId(): ?string
{
// Return a non-empty string to use it as the websiteId (p7),
// or null to defer to the next provider in the chain.
return 'my-id';
}
}
Comment on lines +107 to +123

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example showing how you could set the website ID by integrating it with a custom CRM if you use one. This one shows also how to handle the anonymous user.

Suggested change
<?php
declare(strict_types=1);
namespace App\Tracking;
use Ibexa\Contracts\ConnectorRaptor\Tracking\ContextProvider\WebsiteIdContextProviderInterface;
final class MyWebsiteIdProvider implements WebsiteIdContextProviderInterface
{
private const string WEBSITE_ID = 'ibexa_user_get_current().login';
public function getWebsiteId(): string
{
return self::WEBSITE_ID;
}
}
namespace App\Tracking;
use Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface;
use Ibexa\Contracts\Core\Repository\PermissionResolver;
use Ibexa\Contracts\ConnectorRaptor\Tracking\ContextProvider\WebsiteIdContextProviderInterface;
final class MyCrmWebsiteUserIdProvider implements WebsiteIdContextProviderInterface
{
public function __construct(
private ConfigResolverInterface $configResolver,
private PermissionResolver $permissionResolver,
)
{
}
public function getWebsiteId(): ?string
{
$currentUserId = $this->permissionResolver->getCurrentUserReference()->getUserId();
// Don't resolve for anynomous user
if ($this->isAnonymousUser($currentUserId)) {
return null;
}
return $this->getWebsiteUserIdForCurrentUser($currentUserId);
}
/**
* @phpstan-return non-empty-string
*/
private function getWebsiteUserIdForCurrentUser(int $userId): string
{
// Implement custom logic resolving user identifier from the CRM
return 'custom-identifier-for-the-user-retrieved from-the-CRM';
}
private function isAnonymousUser(int $userId): bool
{
return (int) $this->configResolver->getParameter('anonymous_user_id') === $userId;
}
}

If we go with this one, the sentences below are out of date.

```

The provider is registered automatically.

Check notice on line 126 in docs/templating/twig_function_reference/recommendations_twig_functions.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/templating/twig_function_reference/recommendations_twig_functions.md#L126

[Ibexa.Passive] Try to avoid passive tense, when possible.
Raw output
{"message": "[Ibexa.Passive] Try to avoid passive tense, when possible.", "location": {"path": "docs/templating/twig_function_reference/recommendations_twig_functions.md", "range": {"start": {"line": 126, "column": 14}}}, "severity": "INFO"}
Implementing the interface is sufficient, no service configuration is required.

Check notice on line 127 in docs/templating/twig_function_reference/recommendations_twig_functions.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/templating/twig_function_reference/recommendations_twig_functions.md#L127

[Ibexa.Passive] Try to avoid passive tense, when possible.
Raw output
{"message": "[Ibexa.Passive] Try to avoid passive tense, when possible.", "location": {"path": "docs/templating/twig_function_reference/recommendations_twig_functions.md", "range": {"start": {"line": 127, "column": 68}}}, "severity": "INFO"}

!!! note

Custom provider takes precedence over the built-in one.
A provider must return either null or a non-empty string.

If you register multiple providers, control their order by tagging the service with a priority (higher priority is checked first):

Check notice on line 134 in docs/templating/twig_function_reference/recommendations_twig_functions.md

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/templating/twig_function_reference/recommendations_twig_functions.md#L134

[Ibexa.Passive] Try to avoid passive tense, when possible.
Raw output
{"message": "[Ibexa.Passive] Try to avoid passive tense, when possible.", "location": {"path": "docs/templating/twig_function_reference/recommendations_twig_functions.md", "range": {"start": {"line": 134, "column": 113}}}, "severity": "INFO"}

``` php
App\Tracking\MyWebsiteIdProvider:
tags:
- { name: ibexa.connector.raptor.tracking.website_id_context_provider, priority: 50 }
```

### Tracking events

The following events are supported and can be triggered from Twig templates:
Expand Down
Loading