/// <summary>
/// Factory for creating a concrete instance of the tracker
base
/// </summary>
public static class TrackerFactory
{
/// <summary>
/// Returns a concrete tracker that is specific to the
current version of Siteccore.
/// NOTE: This is an attempt to defend against future changes
in the Sitecore analytics API.
/// </summary>
/// <returns>A concrete tracker instance</returns>
public static AbstractTrackerBase GetTracker()
{
return new SitecoreDmsTracker();
// NOTE:
implement a new tracker for xDB and return it here
}
}
SitecoreDmsTracker is a concrete class (with method implementations) that gets returned here. You can substitute some other class down the road.
namespace HA.Web.Analytics.Tracking.Base
{
/// <summary>
/// Tracker base class defines methods that aren't specific
to OMS/DMS/xDB APIs
/// </summary>
public abstract class AbstractTrackerBase
{
#region
Virtual Members
/// <summary>
/// Attempts to cancel the current sitecore page, thereby
excluding it from Sitecore analytics
/// </summary>
/// <returns>true if the page could be canceled</returns>
public virtual bool TryCancelCurrentPage()
{
// Don't
bother if analytics isn't running
if (!IsAnalyticsEnabled())
{
return false;
}
try
{
CancelCurrentPage();
return true;
}
catch
{
return false;
}
}
=========================
"sealed" must be used for overrides.When applied to a class, the sealed modifier prevents other classes from inheriting from it.
"sealed" must be used for overrides.When applied to a class, the sealed modifier prevents other classes from inheriting from it.
namespace HA.Web.Analytics.Tracking.Trackers
{
/// <summary>
/// A DMS specific implementation of the tracker base
/// </summary>
public sealed class SitecoreDmsTracker : AbstractTrackerBase
{
public const string _VisitorTestTagName = "MULTIVARIATE_TEST_NAME";
public const string _VisitorTestCookieName = "VisitorMultivariateTestCookie";
/// <summary>
/// Determines if the current visitor has a specific pattern
card
/// </summary>
/// <param
name="profileName">The name of the
profile grouping</param>
/// <param
name="patternLabel">The name
of the pattern label to match</param>
/// <param
name="utcCutoffDateTime">An
optional cuttoff date to exclude old data</param>
/// <returns>true if the visitor has a pattern card</returns>
public override bool VisitorHasPatternCard(string profileName, string patternLabel, DateTime? utcCutoffDateTime)
{
No comments:
Post a Comment