更新:所以问题是我的应用程序Global.asax.cs并非源自Sitecore.Web.Application。
所以我刚刚使用MongoDB 2.6.11安装了Sitecore 8。
出于测试目的,我将下面的代码放在页面加载事件中,以激活我之前在sitecore中创建的目标。
目标是通过部署和发布成功创建的。我还确认了目标的项目ID是正确的。
if (Sitecore.Analytics.Tracker.IsActive && Sitecore.Analytics.Tracker.Current.CurrentPage != null)
{
Sitecore.Data.Items.Item GoaltoTrigger = Sitecore.Context.Database.GetItem("{EDA8EA2C-7AF5-4D0F-AF76-A9C4E6BD7169}");
if (GoaltoTrigger != null)
{
Sitecore.Analytics.Data.Items.PageEventItem registerthegoal = new Sitecore.Analytics.Data.Items.PageEventItem(GoaltoTrigger);
Sitecore.Analytics.Model.PageEventData eventData = Sitecore.Analytics.Tracker.Current.CurrentPage.Register(registerthegoal);
eventData.Data = GoaltoTrigger["Description"];
Sitecore.Analytics.Tracker.Current.Interaction.AcceptModifications();
}
}
Session.Abandon();
可悲的是,这不起作用,我无法在交互下的xDB中看到目标。
我调查过的其他事情是我的布局肯定有标签
<sc:VisitorIdentification runat="server" />
我的Global.asax实现了Sitecore.Web.Application
public class Global : Sitecore.Web.Application
但没有运气。在Mongo中无法看到交互(使用mongo shell和roboMongo来查找集合)。我错过了别的什么吗?
Sitecore错误
ManagedPoolThread #3 16:43:00 INFO Job ended: Sitecore.ListManagement.Analytics.UnlockContactListsAgent (units processed: )
12980 16:43:05 INFO Cache created: '[no name]' (max size: 976KB, running total: 2918MB)
12980 16:43:05 INFO Cache created: '[no name]' (max size: 976KB, running total: 2919MB)
12980 16:43:05 INFO Cache created: '[no name]' (max size: 976KB, running total: 2920MB)
12980 16:43:05 INFO Cache created: '[no name]' (max size: 976KB, running total: 2921MB)
12980 16:43:05 INFO Cache created: '[no name]' (max size: 976KB, running total: 2922MB)
ManagedPoolThread #5 16:43:06 ERROR Failed to perform MaxMind lookup
ManagedPoolThread #5 16:43:06 ERROR Failed to perform GeoIp lookup for 127.0.0.1
Exception: Sitecore.Analytics.Lookups.CannotParseResponseException
Message: Unexpected format. Cannot parse the MaxMind response for IP address: 127.0.0.1
Source: Sitecore.Analytics
at Sitecore.Analytics.Lookups.MaxMindProvider.GetInformationByIp(String ip)
at Sitecore.Analytics.Lookups.GeoIpManager.GetDataFromLookupProvider(GeoIpHandle geoIpHandle)
12980 16:43:08 INFO Cache created: 'WebUtil.QueryStringCache' (max size: 19KB, running total: 2922MB)
2700 16:43:08 INFO HttpModule is being initialized
12360 16:43:08 INFO HttpModule is being initialized
7068 16:43:08 INFO HttpModule is being initialized
9940 16:43:10 INFO [Experience Analytics]: Reduce agent found zero segments to process
ManagedPoolThread #1 16:43:10 INFO Job started: Sitecore.ListManagement.Analytics.UnlockContactListsAgent
ManagedPoolThread #1 16:43:10 INFO Job ended: Sitecore.ListManagement.Analytics.UnlockContactListsAgent (units processed: )
答案 0 :(得分:11)
首先,这是触发目标的正确方法:
if (Sitecore.Analytics.Tracker.IsActive)
{
if (Sitecore.Analytics.Tracker.Current.CurrentPage != null)
{
var goalId = new Sitecore.Data.ID("{EDA8EA2C-7AF5-4D0F-AF76-A9C4E6BD7169}");
Sitecore.Analytics.Data.Items.PageEventItem goalToTrigger =
Sitecore.Analytics.Tracker.DefinitionItems.PageEvents[goalId];
if (goalToTrigger != null)
{
Sitecore.Analytics.Model.PageEventData eventData =
Sitecore.Analytics.Tracker.Current.CurrentPage.Register(goalToTrigger);
}
else
{
Sitecore.Diagnostics.Log.Error("Goal with ID " + goalId + " does not exist", this);
}
}
else
{
Sitecore.Diagnostics.Log.Error("Tracker.Current.CurrentPage is null", this);
}
}
else
{
Sitecore.Diagnostics.Log.Warn("The tracker is not active. Unable to register the goal.", this);
}
您注册后不应尝试更改事件数据。
另外,你不应该调用Interaction.AcceptModifications()
,因为这个方法是xDB在某些时候内部使用的。
CurrentPage.Register()
是您唯一需要做的事情。
我不建议使用Session.Abandon()
。它可能会导致您将交互保存到集合数据库,但这样就会破坏Sitecore会话的正常流程。这可能导致的一个问题是,交互的联系人将保持锁定21分钟(或者无论您的会话超时设置为+ 1分钟)。
相反,出于测试目的,我建议您将会话超时设置为1分钟,并在最后一页请求后等待1分钟。此设置位于 Web.config 中,作为<sessionState>
的属性。
analytics
连接字符串。Sitecore.OMS
b)在Sitecore 8.1中Sitecore.xDB.base
。Analytics.Enabled
应设置为 Sitecore.Analytics.config 中的true
。Xdb.Enabled
和Xdb.Tracking.Enabled
都应设置为true
。< / LI>
<sites>
部分,然后检查enableAnalytics
是否< / strong>在false
或您正在使用的任何网站上设置为<site name="website">
b)在Sitecore 8.1中,您应确保 Sitecore.config 中的enableTracking
为您的网站设置为true
。Analytics.Robots.IgnoreRobots
和Analytics.AutoDetectBots
设置为false
来禁用机器人检测。如果在此之后保存了相互作用,我将通过进一步说明更新我的回答。