Custom computed fields in Tealium Tag Management for Sitecore

In the last blog post we looked at Tealium tag management for Sitecore. In this post we will cover customization available to enabled computed fields. By default you have access to the following out of the box fields:

We also saw in the last post about how to add custom tags with fixed values (site_currency: [“USD”,”EUR”]). In the next post we will look at template specific tags and how we can render them.

For the purposes of this blog post, lets assume that we want the item url to be rendered as a tag. In order to make this available globally we can enable the Custom UDO property in /sitecore/system/Modules/Tealium Tag Management/Settings/Tealium Settings.

In order to do that we need to write some code which will inherit the IComputedFieldMapper interface.

XHTML

1

2

3

4

5

6

7

8

9

10

usingSystem.Collections.Generic;

namespaceTealium.Sitecore.TagManagement.Mappings

{

publicinterfaceIComputedFieldMapper

{

voidAddComputedFields(IDictionary&lt;string,object&gt;utagParams);

}

}

Follow the steps below:

In your assembly add a reference to the Tealium.Sitecore.TagManagement.dll

Create a class TealiumComputedFields and inherit the IComputedFieldMapper, be sure to implement that interface

This will force you to define the AddComputedFields method, here add your code for the tags you would like to render

Set the Custom UDO Type based on the information from your assembly (YOURNAMESPACE.TealiumComputerFields,YOURASSEMBLY)

Sad part is that you only get one custom computed fields library and if you need to cater to multiple templates or render based on multiple templates, you have to end up using switch/if statements to do conditional logic based on template.

no comment

This is a personal blog. Any views or opinions represented in this blog are my own and do not represent those of people, institutions or organizations that the I may or may not be associated with in professional or personal capacity including past, current and future employers, unless explicitly stated.