Sitecore Boost User Pattern Programmatically

Following my post on how to prevent Sitecore from tracking the user pattern, I am writing today on how to boost the user pattern programmatically. The reason I am writing this up is because there were some question about it on the Sitecore StackExchange and also, I had been given a task where I should boost the user pattern on certain conditions. So, let’s proceed.

Suppose we have the following scenario: When a user has triggered a goal, example registration, the user pattern needs to be updated to Registered User. From the code, after the user has triggered the goal, you’ll need to call the below method.

The above code will first get the pattern card based on the pattern name provided as parameter. If exists, we will get the pattern card. We need to also retrieve the existing profile of the user by using the pattern card item.

The next method (BoostUserPattern) is called. Sitecore stores the tracking information as xml. At this point, the method will read into the pattern field to extract the xml. Once the xml is obtained, we set all the different keys’ score to 0. We need now to update the score of the specific key(s) that we require to boost the user pattern to the register one. For the sake of this blog, I assume that 5 is the highest possible value.

We need to re-associate the user with the updated pattern. Finally, we need to update the Sitecore Behavioral Profile. This may be optional unless you are preventing Sitecore from tracking the user pattern for a specific profile.

 

Advertisements

One thought on “Sitecore Boost User Pattern Programmatically

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s