Monday, 30 November 2015

Sitecore Pipelines - DetermineInteractionChannel

This post documents Sitecore's DetermineInteractionChannel pipeline, and is part of a series providing information on all the pipelines and processors in involved in a Sitecore 8 request. It's not a line by line account, but all the key logic is described.

I'd like the post to develop over time, so if you find any inaccuracies or would like to contribute more information, then please leave a comment. Better still, contact me on Twitter.

All information has been written with reference to Sitecore 8 (rev 141212)

The DeterminInteractionChannel pipeline is quite simple. It's called from the SetChannel processor in the CreateVisit pipeline. The primary focus of each processor is to set the value of the args.ChannelId property. It appears to have been designed to closely mimic the TrafficTypes pipeline which runs immediately before it.

Like the TrafficTypes pipeiline, DetermineInteractionChannel does not abort when the when the primary goal has been achieved. So args.ChannelId may be overwritten several times during the course of the pipeline. You should be mindful of this when adding your own additional processors.



DefaultChannel

Namespace: Sitecore.Analytics.OmniChannel.Pipelines.DetermineInteractionChannel
Assembly: Sitecore.Analytics.OmniChannel
The DefaultChannel processor is very simple. It initializes args.ChannelId with a default GUID passed in from the Sitecore configuration.

Note that DefaultChannel appears to correspond to Intialize in the TrafficTypes pipeline.



ReferringSite

Namespace: Sitecore.Analytics.OmniChannel.Pipelines.DetermineInteractionChannel
Assembly: Sitecore.Analytics.OmniChannel
The ReferringSite processor is responsible for setting args.ChannelId depending on whether the request is a referral (i.e. the user clicked a hyperlink on another site). It has the following requirements:

  • args.Interaction.Referrer must not be null or empty.
  • Tracker.Dictionaries.ReferringSites must not be null.

If either of these criteria are not met, then the processor returns without performing any actions.

If args.Interaction.ReferringSite is the key of an item in the Tracker.Dictionaries.ReferringSites dictionary, then args.ChannelId is set to that dictionary items's ChannelId property. Otherwise, args.ChannelId is set to the "Referred Other" channel ID passed in from the constructor.

Note that the ReferringSite processor is very similar to the processor of the same name in the TrafficTypes pipieline.



SearchKeywords

Namespace: Sitecore.Analytics.OmniChannel.Pipelines.DetermineInteractionChannel
Assembly: Sitecore.Analytics.OmniChannel
The SearchKeywords processor is responsible for setting args.ChannelId based on whether the request originated from a search engine result. It simply checks the value of args.Interaction.Keywords. If that isn't null or empty, then args.Channel is set to the ID of the "Non-Branded Organic Search" channel ID passed in from the constructor.

Note that SearchKeywords is very similar to processor of the same name in the TrafficTypes pipeline.



OrganicBranded

Namespace: Sitecore.Analytics.OmniChannel.Pipelines.DetermineInteractionChannel
Assembly: Sitecore.Analytics.OmniChannel
The OrganicBranded processor is responsible for setting args.ChannelId based on whether the current interaction's keywords match any in a predetermined list. It initially checks the args.Interaction.Keywords property. If it's null or empty then the processor returns without performing any actions.

Next, the processor gets the object at the path "/sitecore/system/Settings/Analytics/Organic Branded Keywords" within the Tracker.DefinitionDatabase (it returns without doing anything if the item doesn't exist).

The value of the  item's "Keywords" field is read and converted in to an array of strings (delimited by a line break). If the array contains the value of args.Interaction.Keywords, then args.ChannelId is set to the the ID of the "Branded Organic" channel item (The ID is passed in via the constructor).

Note that OrganicBranded is very similar to (possibly even copy/pasted from) the processor of the same name in the TrafficTypes pipeline.