Tuesday, 7 January 2014

Targeting Content based on Context

With the release of SDL Tridion 2013 SP1 the concept of context becomes even more an integral part of the SDL technology suite.

One headline of this release is the start of contextual templating.
It’s only a start, because we’re already working on the next generation of template rendering, which will enhance the component based rendering, i.e. rendering of things, along with template inheritance.
This next generation will bring an extra level of agility in the way that you can efficiently manage the tweaking of content on a per context basis.
Agility, because you will be able to have full control over content rendering changes on a per context basis with zero regression risk to other contexts - this is great if you need to get quality controlled changes out in minutes instead of days or weeks. Efficiently, since you will be able to radically reduce any repetition in your templates and manage contextual variations in such a way it’s easier for different members of the team to get working … however, I’m running ahead of myself a little.

Let’s get back to what you can use today and start with some fundamentals.

Imagine you’ve just released a new iOS and Android app and you want to promote this new app to your users.

<context:if expression="os.model == 'iOS'">
  Would you like to try our new 
  <context:eval expression="device.model"> app? 
  - <a href="... apple app store link ...">download now</a>;
</context:if>

<context:if expression="os.model == 'Android'">
  Would you like to try our new Android app? 
  - <a href="... google app store link ... “>download now</a>
</context:if>

You may also have looked Android version usage and realised that about 25% of people are not yet on Android v4 - Ice Cream Sandwich and beyond - and you’ve realised that the app you’ve release for Android is only supported on v4.

You clearly don’t want to promote this app to people who would be frustrated to find they can use it. You can change the context expression to accommodate this.

<context:if expression="os.model == 'Android' and os.version ge 4">
  Would you like to try our new Android app?
  - <a href=" ... google app store link ... ">download now</a>
</context:if>

These contextual controls are available to you in a variety of templating languages - in .NET Web Forms you may see

<context:If ID="android-app" Expression="os.model == 'Android'" runat="server">
  Would you like to try our new Android app?
  - <a href=" ... google app store link ... ">download now</a>
</context:If>

with the following Web.config control defined.

<add tagPrefix="context" 
  namespace="Tridion.Context.ServerControls.Web.UI" 
  assembly="Tridion.Context.ServerControls" /> 

In JSP you might see

<context:if expression="os.model == 'Android'">
  Would you like to try our new Android app? 
  - <a href=" ... google app store link ... ">download now</a>
</context:if>

with the following tag lib defined.

<%@taglib prefix="context" uri="http://context.sdl.com/taglib" %>

In Tridion templates you might see

<tcdl:if expression="os.model == 'Android'">
  Would you like to try our new Android app? 
  - <a href=" ... google app store link ... ">download now</a>
</tcdl:if>

If these Tridion templates are deployed into a JSP or .NET MVC environments then these tcdl controls are transformed into the JSP and .NET Web Forms counterparts.

This shows a quick example on how you can start access the context and in particular the os aspect. Other browser and device properties are available, for example, you may wish to deliver a different variation in the rendering for small screens vs large screen to achieve an optimised user experience on the small screen. Your optimised experience may provide :

  • fine tuned user journey
  • mobile focused menu
  • lighter pages - less bandwidth & faster loading

Enjoy and … more tips to follow.