Woopra Templates
Templates are used to dynamically insert content into text placeholders. These are used in our Schemas and in our Automation and Triggers.
There are two main uses for Woopra templates:
- Determining how an event looks in the user profile (i.e: "Viewed Page /docs" instead of "Did pageview").
- Using event and user properties in the configuration of an automation like a trigger, for instance when sending a text message or transactional email in which you want to include a user property like the person's name, or an event property like the url of their abandoned cart.
The Templating System
Woopra templates use the ${
and }
format for template expressions. In general the format will be:
${<SCOPE>(user|event|visit).<property name>}
.
The available scopes are user
, event
, and visit
. The user scope means user properties like a user's first_name
. The Event scope means event/event properties, like the url
of a pageview event. The visit scope has session level properties such as browser
or ip
.
Templating Values
The SCOPE part allows you to declare if you are referring to a session/visit property, a user property, or to an event property of the current event (in the case of a trigger, this would be the event that is selected in the "trigger when" section when you define your trigger.)
To see what event properties are available for a given event, it is best to go check out your event schemas in the Woopra interface: Configure > Event Schemas. Similarly, you can see what properties/fields you have defined in your schemas for users in Configure > user Schemas.
A visit
scope allows you to use a visit property which actually applies to many events. For instance things like: ip address, referer/source, Operating system, browser, etc. are all visit properties and can be accessed in templates using, e.g.: ${visit.browser}
For more on the visit scope and properties, see User Properties, and finally Generated Visit Properties which discusses a few properties like browser
that are generated automatically when possible, and generally available in any templating situation. They are not always present, however. For example, you wouldn't expect to have a visit.browser
on a session that only includes a serverside event like "email bounced" in which the user never actively used a browser to interact with your system.
Escaping JSON
Woopra also supports escaping values that are injected into a Javascript context. For example, you can use ${user.name | json}
to escape the text into "First Last"
.
Updated 9 months ago