Skip to main content
Version: 2026.2

Events

The targeting engine dispatches Symfony events throughout the request lifecycle, and the Pimcore Studio backend fires pre-response events for the Personalization API. Subscribe to these events to hook into targeting without overriding the engine's services.

Targeting Lifecycle Events

Defined as constants on TargetingEvents:

ConstantEvent nameEvent classDispatched from
PRE_RESOLVEpimcore.targeting.pre_resolveTargetingResolveVisitorInfoEventVisitorInfoResolver::resolve(), before matching starts
POST_RESOLVEpimcore.targeting.post_resolveTargetingEventVisitorInfoResolver::resolve(), after all rules matched
PRE_RULE_ACTIONSpimcore.targeting.pre_rule_actionsTargetingRuleEventVisitorInfoResolver, when a rule matches, before its actions run
POST_RULE_ACTIONSpimcore.targeting.post_rule_actionsTargetingRuleEventVisitorInfoResolver, when a rule matches, after its actions ran
BUILD_CONDITIONpimcore.targeting.build_conditionBuildConditionEventConditionFactory::build(), see Conditions
ASSIGN_DOCUMENT_TARGET_GROUPpimcore.targeting.assign_document_target_groupAssignDocumentTargetGroupEventDocumentTargetGroupListener, once per target group configured on a document's Target Groups panel
TARGETING_CODEpimcore.targeting.targeting_codeTargetingCodeEventTargetingCodeGenerator::generateCode(), see Frontend JavaScript
RENDER_TOOLBARpimcore.targeting.render_toolbarRenderToolbarEventToolbarListener, before rendering the on-page debug toolbar
VISITED_PAGES_COUNT_MATCHpimcore.targeting.visited_pages_count_matchSymfony\Component\EventDispatcher\GenericEventVisitedPagesBefore::postMatch(), internal signal consumed by VisitedPagesCountListener to increment the visited-page count

PRE_RESOLVE is documented on TargetingEvents as carrying a TargetingEvent, but the actual dispatch uses the subclass TargetingResolveVisitorInfoEvent, which additionally exposes setVisitorInfo() so a listener can swap in a different VisitorInfo instance before matching runs.

VISITED_PAGES_COUNT_MATCH is internal bookkeeping for the Visited Pages Before condition rather than a general extension point, and carries no custom payload.

Example: Reacting to Rule Matches

<?php

namespace App\EventListener;

use Pimcore\Bundle\PersonalizationBundle\Event\Targeting\TargetingRuleEvent;
use Pimcore\Bundle\PersonalizationBundle\Event\TargetingEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class RuleMatchedListener implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
TargetingEvents::POST_RULE_ACTIONS => 'onRuleMatched',
];
}

public function onRuleMatched(TargetingRuleEvent $event): void
{
$rule = $event->getRule();
$visitorInfo = $event->getVisitorInfo();

// e.g. forward the match to an analytics system
}
}

Target Group Model Events

Defined as constants on TargetGroupEvents, all carrying an Event\Model\TargetGroupEvent with the affected TargetGroup model:

ConstantEvent nameDispatched from
POST_ADDpimcore.targetgroup.postAddTargetGroup::save(), when creating a new target group
POST_UPDATEpimcore.targetgroup.postUpdateTargetGroup::save(), when updating an existing target group
POST_DELETEpimcore.targetgroup.postDeleteTargetGroup::delete()

Pimcore Studio Pre-Response Events

warning

The Personalization Studio API controllers under Controller/Studio are internal and may change without notice; do not call them directly. The pre-response events below are the supported extension point: they let you add custom data to the API response schemas the Studio frontend consumes. See the Studio Backend Bundle's Additional and Custom Attributes documentation for the general mechanism.

Event nameEvent classDispatched from
pre_response.personalization.target_group.listPreResponse\TargetGroupEventTargetGroupService::listTargetGroups(), once per persisted target group. The synthetic default entry added when includeDefault is requested is appended outside the dispatch loop and does not fire the event
pre_response.personalization.target_group.detailPreResponse\TargetingGroupDetailEventTargetGroupService::getGroup()
pre_response.personalization.targeting_rule.listPreResponse\TargetingRuleEventTargetingRuleService::listRules(), once per rule in the list
pre_response.personalization.targeting_rule.detailPreResponse\TargetingRuleDetailEventTargetingRuleService::getRule()

Each event exposes the response schema object (for example getTargetGroup(), getTargetingRuleDetail()) and, through the shared AbstractPreResponseEvent base class, hasAdditionalAttribute(), getAdditionalAttribute(), addAdditionalAttribute() and removeAdditionalAttribute() to add or read custom data on the response.