将 Sitecore 访问者映射到自定义频道
Map a Sitecore visitor to a custom Channel
我有一些附属网站,link 到我的 Sitecore 网站。
我为这些附属网站创建了自定义频道。我想要做的是根据引用的 HTTP header 将这些访问者映射到自定义频道,这样我就可以根据频道对组件进行个性化设置。
我认为 Sitecore 没有很好地记录这部分内容,而且我在 Internet 上也找不到太多内容。
我该怎么做?
我是否需要编写自己的管道,或者这是 Sitecore 中的默认功能?
编辑:
interactionChannelMappings
应该有办法做到这一点
这是 Sitecore.Social.config
文件
中的一些 xml
<interactionChannelMappings>
<!-- 41-91-05: Online/Social Community/Facebook Social Community -->
<channel channelId="{A9F2D058-95A5-4461-B1E5-8502D2303AF1}">
<!-- Facebook -->
<channelMapping urlReferrerHost="www.facebook.com" />
<!-- Facebook for mobile -->
<channelMapping urlReferrerHost="m.facebook.com" />
<!-- Facebook's Link Shim -->
<channelMapping urlReferrerHost="l.facebook.com" />
<!-- Facebook's Link Shim for mobile -->
<channelMapping urlReferrerHost="lm.facebook.com" />
</channel>
</interactionChannelMappings>
看起来像通配符。但是我到底应该把它放在哪里(我不想把它放在 Sitecore.Social.config
文件中。我还需要什么其他代码?除了 this[,我在 Sitecore 网站上找不到任何文档=15=]
将访问映射到渠道的一种方法是使用广告系列,但这需要 link 包含广告系列标识符。
另一种方法是使用 API 设置当前交互的 ChannelId。正如您已经提到的那样,这可以在管道中完成,以确保它在每个请求上完成(实际上会话的第一个请求就足够了)。
不过可能还有其他方法...
编辑使用 API:像这样创建一个 class 并将其添加到默认 SetChannel 之后的 CreateVisit 管道中(使用配置补丁)。
public class SetChannel : CreateVisitProcessor
{
public override void Process(CreateVisitArgs args)
{
Guid channelID = ... // Get your channel ID
args.Interaction.ChannelId = channelID;
}
}
Edit2:interactionChannelMappings 确实是一个选项。我自己从未尝试过,但使用配置补丁可以很容易地添加您的频道及其映射。在查看读取该配置时执行的代码时,它应该做你想做的(即根据引荐来源网址设置频道)。所以不需要自定义代码。
可以在此处找到有关配置修补的更多信息:https://community.sitecore.net/technical_blogs/b/sitecorejohn_blog/posts/all-about-web-config-include-files-with-the-sitecore-asp-net-cms。如有疑问,请使用 /sitecore/admin/showconfig.aspx
.
检查结果
这就是我要找的:
创建自己的频道项目,例如:
/sitecore/system/Marketing Control Panel/Taxonomies/Channel/Online/Affiliates/Site2
创建自己的流量类型:
/sitecore/system/Settings/Analytics/Traffic Type/Affiliate
Add the channel mapping 到 Sitecore.Analytics.Compatibility.config:
<add trafficType="TRAFFIC-ID" channel="{CHANNEL-ITEM-GUID}" />
使用以下内容创建一个新的 .config:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<social>
<interactionChannelMappings>
<channel channelId="{CHANNEL-ITEM-GUID}">
<!-- affiliate wildcards -->
<channelMapping urlReferrerHost="site2.com" />
</channel>
</interactionChannelMappings>
</social>
</sitecore>
</configuration>
来自 site2.com 的访问现在应自动映射到新创建的自定义渠道
我有一些附属网站,link 到我的 Sitecore 网站。
我为这些附属网站创建了自定义频道。我想要做的是根据引用的 HTTP header 将这些访问者映射到自定义频道,这样我就可以根据频道对组件进行个性化设置。
我认为 Sitecore 没有很好地记录这部分内容,而且我在 Internet 上也找不到太多内容。
我该怎么做? 我是否需要编写自己的管道,或者这是 Sitecore 中的默认功能?
编辑:
interactionChannelMappings
应该有办法做到这一点
这是 Sitecore.Social.config
文件
<interactionChannelMappings>
<!-- 41-91-05: Online/Social Community/Facebook Social Community -->
<channel channelId="{A9F2D058-95A5-4461-B1E5-8502D2303AF1}">
<!-- Facebook -->
<channelMapping urlReferrerHost="www.facebook.com" />
<!-- Facebook for mobile -->
<channelMapping urlReferrerHost="m.facebook.com" />
<!-- Facebook's Link Shim -->
<channelMapping urlReferrerHost="l.facebook.com" />
<!-- Facebook's Link Shim for mobile -->
<channelMapping urlReferrerHost="lm.facebook.com" />
</channel>
</interactionChannelMappings>
看起来像通配符。但是我到底应该把它放在哪里(我不想把它放在 Sitecore.Social.config
文件中。我还需要什么其他代码?除了 this[,我在 Sitecore 网站上找不到任何文档=15=]
将访问映射到渠道的一种方法是使用广告系列,但这需要 link 包含广告系列标识符。
另一种方法是使用 API 设置当前交互的 ChannelId。正如您已经提到的那样,这可以在管道中完成,以确保它在每个请求上完成(实际上会话的第一个请求就足够了)。
不过可能还有其他方法...
编辑使用 API:像这样创建一个 class 并将其添加到默认 SetChannel 之后的 CreateVisit 管道中(使用配置补丁)。
public class SetChannel : CreateVisitProcessor
{
public override void Process(CreateVisitArgs args)
{
Guid channelID = ... // Get your channel ID
args.Interaction.ChannelId = channelID;
}
}
Edit2:interactionChannelMappings 确实是一个选项。我自己从未尝试过,但使用配置补丁可以很容易地添加您的频道及其映射。在查看读取该配置时执行的代码时,它应该做你想做的(即根据引荐来源网址设置频道)。所以不需要自定义代码。
可以在此处找到有关配置修补的更多信息:https://community.sitecore.net/technical_blogs/b/sitecorejohn_blog/posts/all-about-web-config-include-files-with-the-sitecore-asp-net-cms。如有疑问,请使用 /sitecore/admin/showconfig.aspx
.
这就是我要找的: 创建自己的频道项目,例如:
/sitecore/system/Marketing Control Panel/Taxonomies/Channel/Online/Affiliates/Site2
创建自己的流量类型:
/sitecore/system/Settings/Analytics/Traffic Type/Affiliate
Add the channel mapping 到 Sitecore.Analytics.Compatibility.config:
<add trafficType="TRAFFIC-ID" channel="{CHANNEL-ITEM-GUID}" />
使用以下内容创建一个新的 .config:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<social>
<interactionChannelMappings>
<channel channelId="{CHANNEL-ITEM-GUID}">
<!-- affiliate wildcards -->
<channelMapping urlReferrerHost="site2.com" />
</channel>
</interactionChannelMappings>
</social>
</sitecore>
</configuration>
来自 site2.com 的访问现在应自动映射到新创建的自定义渠道