With target groups it is possible to categorize anonymous visitors into segments. Once categorized your web site can be built to respond with different promotions and content to different target groups.
How it works
Target groups are categories of anonymous visitors. Whether or not a visitor belongs to a target group is defined by a set of conditions. Each target group can have several conditions and the target groups and their conditions are managed under Groups in the Relations module.
Conditions included in Litium Studio
These are the conditions shipped with Litium Studio but you can also build your own conditions.
Order conditions
- "Order freguency" - number of placed orders during a specified time interval
- "Order total" - the total sum of placed orders during specified time interval
Site conditions
- "Number of visits on web site" - a user visited the specific web site
- "Visited page" - a user visited a specified page (Note that this does not apply to Redirect pages, for example the Top Menu link page in the Accelerator)
- "Visited product" - a user visited the product detail page of a certain product
- "Visited product group" - a user visited the product detail page of a product belonging to the product group, or the product group page
- "Visited product set" - a user visited the product detail page of a product belonging the product set
Cart conditions
- "Has product in cart" - a user put the specified product to the cart
- "Removed product from cart" - a user put the specified product to the cart and then removed it within the session
- "Has product from product group in cart" - a user put the product of a specified product group to the cart
- "Has product from product set in cart" - a user put the product of a specified product set to the cart
Search conditions
- "Searched on site for" - a user searched for a specified search term. Setting whether to match exact or if search term should contain the word.
- "Searched in Google or Bing for" - a user searched for a specified search term in Google or Bing and entered the site. Setting whether to match exact or if search term should contain the word.
The conditions are all applied only during the user session except for Number of visits on web site, Order frequency and Order Total which persist over brower restarts.
Specify your conditions
When you have added a condition from the list, there is the option to specify different things for the condition to be fulfilled. For example time interval, frequency, search phrase, website, order total, numbers of placed orders and more, depending on the condition.
"Frequency" = The number of times that a visitor behavior has to occur for the condition to be fulfilled.
"Time interval" - The period of time when the user behaviour has to occur for the condition to be fulfilled.
Matching
If you have several conditions for one target group you might want to prioritize or combine them in different ways.
- Match "All" it means that all conditions must be met by the visitor to be added to the group ("AND")
- Match "Any" means that some of the conditions need to be fulfilled ("OR")
- Match "Points" means that conditions will not be fulfilled until they have reached a specific sum of points (read more in the next paragraph)
Required conditions
When matching "Any" conditions, one of the conditions might always be required. Let's say that you want the visitor to have visited your website more than five times and any of three products. Then the first condition is always required, in combination with any of the others, in order to become a member of the target group. If no condition is marked "Required" then any of the conditions is enough to fulfill.
Points
If you want to prioritize between conditions you can assign them different weight, or points. For example, if one product is more important than another you might assign different points to them. You can also work with thresholds. When the sum of points exceeds the threshold value, the condition is met. The points are an abstract measure and you need to make the evaluation according to your business.
Preview a page with different target groups
When editing pages in Web publishing, you can preview how your page responds depending on which target group the visitor belongs to. Simply click a page in the left tree, and select Target group from the Preview button in the toolbar. This can also be done for a working copy when editing a page.
Page template
In your page template code, you can check whether a vistor belongs to a certain target group with the webcontrol or from code behind:
Example using the webcontrol:
<web:IsInTargetGroup name="TargetGroupPropertyName" runat="server">
<ontrue>
Content or other controls that should be shown when visitor is included in the selected target group
</ontrue>
<onfalse>
Content or other controls that are shown in all other cases
</onfalse>
</web:IsInTargetGroup>
Example of check if visitor includes in the target group from code behind
protected void Page_Load(object sender, EventArgs e)
{
if (IsInTargetGroup("TargetGroupPropertyName"))
{
//Some code that should be used if visitor includes in the selected target group
}
}
private bool IsInTargetGroup(string targetGroupName)
{
Property property = WebControlState.CMS.CurrentState.Page.Content[targetGroupName];
if (property != null && property.ValueCount > 0)
{
var targetGroupIdProperty = property as TargetGroupIdProperty;
if (targetGroupIdProperty != null)
{
var engine = IoC.Resolve<ITargetGroupEngine>();
if (engine.IsInTargetGroup(targetGroupIdProperty.GetValue()))
{
return true;
}
}
}
return false;
}
Build your own conditions
Litium Studio is shipped with a number of conditions, but you can of course build your own custom conditions. To build your own conditions you need to create two parts that are connected together: a condition and a condition administration panel with settings for your conditions.
All target group conditions are implemented in the Litium.Foundation.Modules.Relations.Plugins.TargetGroups.ITargetGroupCondition interface. The interface describes all the methods and properties that need to be in the condition and looks as follows:
using System;
using System.Collections.Concurrent;
namespace Litium.Foundation.Modules.Relations.Plugins.TargetGroups
{
/// <summary>
/// Interface ITargetGroupCondition
/// </summary>
public interface ITargetGroupCondition
{
/// <summary>
/// Gets a value indicating whether [allows multiple actions].
/// </summary>
/// <value><c>true</c> if [allows multiple actions]; otherwise, <c>false</c>.</value>
bool AllowsMultipleActions { get; }
/// <summary>
/// Gets a value indicating whether this instance can be used.
/// </summary>
/// <value><c>true</c> if this instance can be used; otherwise, <c>false</c>.</value>
bool CanBeUsed { get; }
/// <summary>
/// Gets the condition group that the condition should be grouped with.
/// The conditions is grouped by "Order", "Cart", "Site", "Search" and then all other in alphabethic order.
/// The translations is from modulestring with key string.Format("TargetGroupGrouping{0}", ConditionGroup).
/// </summary>
/// <value>The condition group.</value>
string ConditionGroup { get; }
/// <summary>
/// Gets the panel path for administration UI.
/// </summary>
/// <value>The panel path.</value>
string PanelPath { get; }
/// <summary>
/// Gets the name.
/// </summary>
/// <param name="languageId">The language Id.</param>
/// <returns></returns>
string GetName(Guid languageId);
/// <summary>
/// Gets the process action.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="targetGroupEvent">The target group event.</param>
/// <returns>TargetGroupProcessAction.</returns>
TargetGroupProcessAction GetProcessAction(ConcurrentDictionary<string, dynamic> context, ITargetGroupEvent targetGroupEvent);
/// <summary>
/// Initializes the specified data.
/// </summary>
/// <param name="data">The data.</param>
void Initialize(dynamic data);
/// <summary>
/// Processes the specified context.
/// </summary>
/// <param name="context">The context.</param>
/// <param name="targetGroupEvent">The target group event.</param>
/// <returns><c>true</c> if processing are succefull, <c>false</c> otherwise.</returns>
bool Process(ConcurrentDictionary<string, dynamic> context, ITargetGroupEvent targetGroupEvent);
}
}
The methods executed in the Target Group Engine is the Initialize and the Process methods.The Initialize is executed when one instance of the condition is added to the Target Group Engine. The value from the data parameter should be stored as a field in the condition implementation to later be used in the Process method to evaluate and make correct choices for the fired ITargetGroupEvent.
The administration interface is implemented in a user control that the PanelPath-property is pointing towards. The user control needs to implement the Litium.Foundation.Modules.Relations.Plugins.TargetGroups.IConditionPanel to be able to handle loading and saving condition data, otherwise you can use all regular controls and build your own user interface to set the values needed to process events to your own target group condition.
The Interface declaration is as follows:
namespace Litium.Foundation.Modules.Relations.Plugins.TargetGroups
{
/// <summary>
/// Interface IConditionPanel
/// </summary>
public interface IConditionPanel
{
/// <summary>
/// Gets the panel data.
/// </summary>
/// <returns>dynamic.</returns>
dynamic GetPanelData();
/// <summary>
/// Initializes the panel data.
/// </summary>
/// <param name="value">The value.</param>
void InitPanelData(dynamic value);
}
}