From a7acb61c15eb8413ecc6f3b8452af41b11a5733d Mon Sep 17 00:00:00 2001 From: julitafalcondusza Date: Tue, 7 Jul 2026 14:43:43 +0200 Subject: [PATCH 1/8] websiteId section added --- .../recommendations_twig_functions.md | 64 ++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/docs/templating/twig_function_reference/recommendations_twig_functions.md b/docs/templating/twig_function_reference/recommendations_twig_functions.md index 6dd1bdddf7..f8956b91bd 100644 --- a/docs/templating/twig_function_reference/recommendations_twig_functions.md +++ b/docs/templating/twig_function_reference/recommendations_twig_functions.md @@ -74,9 +74,71 @@ ibexa_tracking_track_event( - **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()` funtion. + +Example: + +``` html+twig +{{ ibexa_tracking_track_event('visit', product, { + websiteId: 'my-id' +}) }} +``` + +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. + +The value of `websiteId` parameter is resolved in the following order: + +1. Explicit `websiteId` passed in the `ibexa_tracking_track_event()` context. +2. Custom `WebsiteIdContextProviderInterface` implementations (the first one returning a non-null value wins). +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. + +To resolve `websiteId` on the project level, implement the interface as following: + +``` php + Date: Wed, 8 Jul 2026 07:40:16 +0200 Subject: [PATCH 2/8] typos --- .../twig_function_reference/recommendations_twig_functions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/templating/twig_function_reference/recommendations_twig_functions.md b/docs/templating/twig_function_reference/recommendations_twig_functions.md index f8956b91bd..2e7d73a9e2 100644 --- a/docs/templating/twig_function_reference/recommendations_twig_functions.md +++ b/docs/templating/twig_function_reference/recommendations_twig_functions.md @@ -79,7 +79,7 @@ ibexa_tracking_track_event( ### `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()` funtion. +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. Example: @@ -101,7 +101,7 @@ The value of `websiteId` parameter is resolved in the following order: If no value is resolved, the event is sent without the `p7` parameter. -To resolve `websiteId` on the project level, implement the interface as following: +To resolve `websiteId` on the project level, implement the interface as follows: ``` php Date: Wed, 8 Jul 2026 09:21:57 +0200 Subject: [PATCH 3/8] code language fixed --- .../twig_function_reference/recommendations_twig_functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/templating/twig_function_reference/recommendations_twig_functions.md b/docs/templating/twig_function_reference/recommendations_twig_functions.md index 2e7d73a9e2..8eae2c20f8 100644 --- a/docs/templating/twig_function_reference/recommendations_twig_functions.md +++ b/docs/templating/twig_function_reference/recommendations_twig_functions.md @@ -133,7 +133,7 @@ Implementing the interface is sufficient, no service configuration is required. If you register multiple providers, control their order by tagging the service with a priority (higher priority is checked first): -``` php +``` yaml App\Tracking\MyWebsiteIdProvider: tags: - { name: ibexa.connector.raptor.tracking.website_id_context_provider, priority: 50 } From 7e528f806e7267570bacfc50fd83ec12bc379133 Mon Sep 17 00:00:00 2001 From: julitafalcondusza Date: Wed, 8 Jul 2026 10:15:36 +0200 Subject: [PATCH 4/8] fixes, content added --- .../recommendations_twig_functions.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/templating/twig_function_reference/recommendations_twig_functions.md b/docs/templating/twig_function_reference/recommendations_twig_functions.md index 8eae2c20f8..faefa24fb2 100644 --- a/docs/templating/twig_function_reference/recommendations_twig_functions.md +++ b/docs/templating/twig_function_reference/recommendations_twig_functions.md @@ -114,22 +114,24 @@ use Ibexa\Contracts\ConnectorRaptor\Tracking\ContextProvider\WebsiteIdContextPro final class MyWebsiteIdProvider implements WebsiteIdContextProviderInterface { - public function getWebsiteId(): ?string + private const string WEBSITE_ID = 'my-id'; + + 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'; + return self::WEBSITE_ID; } } ``` +Since this provider always returns a value, it narrows the return type to `string`. +If your provider resolves the value conditionally, declare the return type as `?string` and return `null` to allow the next provider in the chain to handle the request. The provider is registered automatically. Implementing the interface is sufficient, no service configuration is required. !!! note Custom provider takes precedence over the built-in one. - A provider must return either null or a non-empty string. + 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): From 3098fe2fb7ea15f04de4a4fe08453ccbf018add2 Mon Sep 17 00:00:00 2001 From: julitafalcondusza Date: Fri, 10 Jul 2026 13:21:23 +0200 Subject: [PATCH 5/8] fixes after rev --- .../recommendations_twig_functions.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/templating/twig_function_reference/recommendations_twig_functions.md b/docs/templating/twig_function_reference/recommendations_twig_functions.md index faefa24fb2..35a36c7030 100644 --- a/docs/templating/twig_function_reference/recommendations_twig_functions.md +++ b/docs/templating/twig_function_reference/recommendations_twig_functions.md @@ -85,7 +85,7 @@ Example: ``` html+twig {{ ibexa_tracking_track_event('visit', product, { - websiteId: 'my-id' + websiteId: 'ibexa_user_get_current().login' }) }} ``` @@ -96,7 +96,7 @@ Both the User ID and the Cookie ID can be used to personalize website modules. The value of `websiteId` parameter is resolved in the following order: 1. Explicit `websiteId` passed in the `ibexa_tracking_track_event()` context. -2. Custom `WebsiteIdContextProviderInterface` implementations (the first one returning a non-null value wins). +2. Custom [`WebsiteIdContextProviderInterface`](/api/php_api/php_api_reference/classes/Ibexa-Contracts-ConnectorRaptor-Tracking-ContextProvider-WebsiteIdContextProviderInterface.html) implementations (the first one returning a non-null value wins). 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. @@ -114,7 +114,7 @@ use Ibexa\Contracts\ConnectorRaptor\Tracking\ContextProvider\WebsiteIdContextPro final class MyWebsiteIdProvider implements WebsiteIdContextProviderInterface { - private const string WEBSITE_ID = 'my-id'; + private const string WEBSITE_ID = 'ibexa_user_get_current().login'; public function getWebsiteId(): string { From 56f934e7a85f9a321e8d03b3c7740cf47773df4f Mon Sep 17 00:00:00 2001 From: julitafalcondusza Date: Mon, 13 Jul 2026 11:33:56 +0200 Subject: [PATCH 6/8] fixes after doc rev --- .../recommendations_twig_functions.md | 56 ++++++++++++------- 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/docs/templating/twig_function_reference/recommendations_twig_functions.md b/docs/templating/twig_function_reference/recommendations_twig_functions.md index 35a36c7030..0aca718d8f 100644 --- a/docs/templating/twig_function_reference/recommendations_twig_functions.md +++ b/docs/templating/twig_function_reference/recommendations_twig_functions.md @@ -79,19 +79,20 @@ ibexa_tracking_track_event( ### `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. +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. -Example: +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: 'ibexa_user_get_current().login' + websiteId: get_custom_crm_identifier(ibexa_user_get_current().login) }) }} -``` -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](https://content.raptorservices.com/help-center/user-tracking-understanding-soft-ids-hard-ids-raptor-identity-matching#:~:text=IDs%3A-,UserId%20%28Website%20ID) or the Cookie ID. The value of `websiteId` parameter is resolved in the following order: @@ -104,27 +105,42 @@ If no value is resolved, the event is sent without the `p7` parameter. To resolve `websiteId` on the project level, implement the interface as follows: ``` php -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 self::WEBSITE_ID; + return (int) $this->configResolver->getParameter('anonymous_user_id') === $userId; } } ``` -Since this provider always returns a value, it narrows the return type to `string`. -If your provider resolves the value conditionally, declare the return type as `?string` and return `null` to allow the next provider in the chain to handle the request. The provider is registered automatically. Implementing the interface is sufficient, no service configuration is required. From cbfaa8b0f5443b0dd33d1ffda12f7544bcc6c308 Mon Sep 17 00:00:00 2001 From: julitafalcondusza Date: Tue, 14 Jul 2026 14:11:43 +0200 Subject: [PATCH 7/8] fixes + rector --- .../twig_function_reference/recommendations_twig_functions.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/templating/twig_function_reference/recommendations_twig_functions.md b/docs/templating/twig_function_reference/recommendations_twig_functions.md index 0aca718d8f..f88c2cd6fb 100644 --- a/docs/templating/twig_function_reference/recommendations_twig_functions.md +++ b/docs/templating/twig_function_reference/recommendations_twig_functions.md @@ -86,9 +86,11 @@ When storing customer data in an external Customer Relationship Management (CRM) 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 +{# Section rendered only for logged-in users #} {{ ibexa_tracking_track_event('visit', product, { websiteId: get_custom_crm_identifier(ibexa_user_get_current().login) }) }} +``` 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. @@ -132,7 +134,7 @@ final class MyCrmWebsiteUserIdProvider implements WebsiteIdContextProviderInterf 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'; + return 'custom-identifier-for-the-user-retrieved-from-the-CRM'; } private function isAnonymousUser(int $userId): bool { From 37b00912a06d1987d3d48214a62264dc09614411 Mon Sep 17 00:00:00 2001 From: julitafalcondusza Date: Tue, 14 Jul 2026 14:57:25 +0200 Subject: [PATCH 8/8] rector fix --- .../twig_function_reference/recommendations_twig_functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/templating/twig_function_reference/recommendations_twig_functions.md b/docs/templating/twig_function_reference/recommendations_twig_functions.md index f88c2cd6fb..1b0dab0de8 100644 --- a/docs/templating/twig_function_reference/recommendations_twig_functions.md +++ b/docs/templating/twig_function_reference/recommendations_twig_functions.md @@ -111,7 +111,7 @@ 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 +final readonly class MyCrmWebsiteUserIdProvider implements WebsiteIdContextProviderInterface { public function __construct( private ConfigResolverInterface $configResolver,