Jeroen
Jeroen

Reputation: 13

Triggering profiles associated with an item in Sitecore

I have a question about triggering profiles associated with an item. If a visitor visits a page, the profiles associated with that page are triggered for that visitor.

How can I trigger the profiles associated with an item in code? The item is not a page. I only want to trigger the profiles if a visitor matches some kind of conidtion.

Thank you!

Upvotes: 1

Views: 283

Answers (1)

nickwesselman
nickwesselman

Reputation: 6890

This is all done through the startTracking pipeline. Unfortunately, it looks as if Sitecore has "hard coded" the pipeline to use the Context Item. You should be able to accomplish this though by replacing the ProcessItem processor.

Note: The following is untested.

  1. Create a subclass of Sitecore.Analytics.Pipelines.StartTracking.StartTrackingArgs which has an Item property
  2. Create a subclass of Sitecore.Analytics.Pipelines.StartTracking.ProcessItem. Use reflector or ILSpy to pull the existing logic of the Process method. If the StartTrackingArgs passed in are of your subclass, and an Item property is specified, use it instead of the context item.
  3. Replace the type of the existing ProcessItem in the startTracking pipeline using an Include config with a patch:attribute.
  4. To trigger the call, construct an instance of your StartTrackingArgs and call Sitecore.Analytics.Pipelines.StartTracking.StartTrackingPipeline.Run(yourArgs).

Upvotes: 2

Related Questions