如何获取 Sitecore 会话期间触发的活动和目标列表?

发布于 2024-12-17 15:57:05 字数 246 浏览 3 评论 0原文

我无法识别通过我们网站的联系表与我们联系的访问者。该表单收集基本信息,但最好在电子邮件正文中包含一些 Sitecore Analytics 数据,以帮助描绘更大的情况。

为了实现这一目标,我需要以某种方式检索当前会话期间触发的所有活动和目标。

Sitecore API 提供了用于“触发”目标和活动的便捷方法,但我似乎找不到任何方法来检索当前会话所触发的内容。如果可能的话,我想避免直接查询 OMS 数据库。

非常感谢任何帮助。

I am having trouble identifying visitors who contact us through our website's contact form. The form collects basic information, but it would be nice to include some Sitecore Analytics data in the body of the email to help paint a bigger picture.

To achieve this, I would need to somehow retrieve all Campaigns and Goals triggered during the current session.

The Sitecore API provides convenient methods for "triggering" goals and campaigns, but I cannot seem to find any methods to retrieve what's been triggered for the current session. I would like to avoid querying the OMS database directly, if possible.

Any help is much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

没︽人懂的悲伤 2024-12-24 15:57:05

您可以深入研究从 Tracker.CurrentVisit 返回的 VisitorDataSet 对象,您应该能够获取一些有用的属性,然后提取相关数据。

例如,这应该让您获得当前访问返回的活动(如果有相关活动)。

if(!Tracker.CurrentVisit.IsCampaignIdNull())
{
    var campaignDataTable = new SharedDataSet.CampaignsDataTable();
    var data = campaignDataTable.FindByCampaignId(Tracker.CurrentVisit.CampaignId); 

    Response.Write("Campaign Name:" + data.CampaignName);
    Response.Write("Id:" + Tracker.CurrentVisit.CampaignId);    
}
else
{
    Response.Write("No campaign found!");
} 

我没有经常使用它,但可能会让您朝着正确的方向前进,抱歉,我无法提供更多详细信息。

You can have a dig around in the VisitorDataSet object returned from Tracker.CurrentVisit, you should be able to get at some useful properties and then extract relevant data.

This, for example, should get you the campaign returned by the current visit (if there is a relevant campaign)..

if(!Tracker.CurrentVisit.IsCampaignIdNull())
{
    var campaignDataTable = new SharedDataSet.CampaignsDataTable();
    var data = campaignDataTable.FindByCampaignId(Tracker.CurrentVisit.CampaignId); 

    Response.Write("Campaign Name:" + data.CampaignName);
    Response.Write("Id:" + Tracker.CurrentVisit.CampaignId);    
}
else
{
    Response.Write("No campaign found!");
} 

I've not used this a lot but might get you going in the right direction, sorry I cant provide any more detail.

善良天后 2024-12-24 15:57:05

我无法得到建议的答案,但我找到了一个可行的解决方案!它应该与 Sitecore 6.5 到 7.2 相关(不确定 7.5 及更高版本)。您可以通过 Sitecore.Analytics.Tracker.DataContext 对象访问营销活动。

将这些知识与 Stephen Pope 的答案相结合,我们得到:

using System.Linq;
using Sitecore.Analytics;

// won't be null if a campaign was triggered
if (!Tracker.CurrentVisit.IsCampaignIdNull())
{
    var campaign = Tracker.DataContext.Where(x => x.ID.Guid == Tracker.CurrentVisit.CampaignId).FirstOrDefault();

    if (campaign != null)
    {
        // do stuff with the campaign here
        var name = campaign.Title;
    }
}

我还关心获取活动的流量类型,您可以这样做:

var trafficType = campaign.SelectTrafficType.TargetItem.Name;

I could not get the proposed answer to work, but I found a solution that does! It should be relevant for Sitecore 6.5 to 7.2 (not sure about 7.5 and beyond). You can access the campaigns through the Sitecore.Analytics.Tracker.DataContext object.

Combining this knowledge with the Stephen Pope's answer, we get:

using System.Linq;
using Sitecore.Analytics;

// won't be null if a campaign was triggered
if (!Tracker.CurrentVisit.IsCampaignIdNull())
{
    var campaign = Tracker.DataContext.Where(x => x.ID.Guid == Tracker.CurrentVisit.CampaignId).FirstOrDefault();

    if (campaign != null)
    {
        // do stuff with the campaign here
        var name = campaign.Title;
    }
}

I also cared about getting the campaign's traffic type, which you can do like so:

var trafficType = campaign.SelectTrafficType.TargetItem.Name;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文