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:

item_id: “{110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9}”
item_language: “en”
item_name: “Home”
item_path: “/sitecore/content/home”
item_template_id: “{32B25AF5-4043-4776-BC20-098339109A4C}”
item_template_name: “Home”

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.

Tealium1

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

Follow the steps below:

  1. In your assembly add a reference to the Tealium.Sitecore.TagManagement.dll
  2. Create a class TealiumComputedFields and inherit the IComputedFieldMapper, be sure to implement that interface
  3. This will force you to define the AddComputedFields method, here add your code for the tags you would like to render
  4. Edit /sitecore/system/Modules/Tealium Tag Management/Settings/Tealium Settings item and check the Enable Custom UDO check box
  5. Set the Custom UDO Type based on the information from your assembly (YOURNAMESPACE.TealiumComputerFields,YOURASSEMBLY)
    Tealium4

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.

Here is the output generated:

As usual if you have any questions or comments, please be sure to ping me.

Thanks.

no comment

Add your comment

Your email address will not be published.