This article is an addition to our main article about the use of Unless properties. In the main article, we explain how to change entire page sections based on Unless properties. Alternatively, you can inject these properties (e.g. a user's location) directly into the page, as described in this article.

How to add Unless properties to your page

In general, you can inject any Unless property into your page and at the end of this article you will find a full list of properties to choose from. To keep it hands on, we will focus on the most common use case - adding a person's location to your website.

First, we will show you how to use one Unless property in combination with a static fallback. Next, we will use two Unless properties, so that the fallback also becomes dynamic - this is mostly useful for the use case "location" since some ISPs disguise the user's exact location. Finally, we will teach you how to add text based on the availability of dynamic information (e.g. add "make an appointment in" if {{geo.city}} is known).


1. How to add a user's location with a static fallback: 

For this, we need to use the Unless property {{geo.city}} and add a fallback. 

Example: We changed the phrase "now available in your city" to "available in {{geo.city}} and kept "your city" as the fallback .

2. How to add a user's location with a dynamic fallback: 

For this, we need to use the Unless property {{geo.city}} and add {{geo.countryName}} as a fallback. 

Example: We changed the phrase "available in your city" to "available in {{geo.city}} and used "available in {{geo.countryName}}" as the fallback. Don't forget to switch the radio button to "Unless property" to make the dynamic fallback work.

3. How to add text based on the availability of a user's location:

If you want to add text only if the value of a dynamic parameter (e.g. {{geo.city}}) is known, you need to write one line of custom Javascript.

if (Txt.get('geo.city')) {
  Txt.set('placeholder', 'Hi there in ' + Txt.get('geo.city'));
}


Example: 

CODE: 

if (Txt.get('geo.city')) {
  Txt.set('session', '- book a yoga session in ' + Txt.get('geo.city'));
}

Result:

Now, if {{geo.city}} is available, the additional text "book a yoga session in {{geo.city}}" will appear. 

4. Most common use cases: 

In general, you can use any Unless property as a dynamic parameter. The most common are:

  • {{geo.city}} → Example: Hi there in {{geo.city}}!
  • {{geo.countryName}}  → Example: Now available in {{geo.countryName}}!
  • {{device.os}} → Example: Our App is available for {{device.os}}!
  • {{parameters.utm_content}} → Example: Buy {{parameters.utm_content}}!
  • {{parameters.xxx}} → Example: Personalize based on parameters send via the URL (scroll to the end of this article for an example).

If you feel using Unless properties for simple statements is too limiting, you can also learn how to show different phrases based on Unless properties.

To give you an example, let's say you have stores in ten different locations. For these you want to use the phrase "Come to our store in Amsterdam/Paris/New York,...". For any other location, you want to switch to "Available online". By writing some JavaScript, you can easily do this:


List of Unless properties: 

DEVICE:

  • "device.isMobile"
    Example:
    if (Txt.get('device.isMobile')) {  Txt.set('dynamic.placeholder', 'Hey Mobile user!');} else {  Txt.set('dynamic.placeholder', 'Default headline!')';}
  • "device.isTablet"  → Example: false
  • "device.isDesktop" → Example: true
  • "device.browser" → Example: Chrome
  • "device.browserLanguage" → Example: en
  • "device.os" → Example: OS X
  • "device.viewSize" → Example: 1862px

LOCATION:

  • "geo.city"
    Example:
    if (Txt.get('geo.city') == 'Amsterdam') {  Txt.set('dynamic.placeholder', 'Special offers for Amsterdam');} else {    Txt.set('dynamic.placeholder', 'Default headline');}
  • "geo.ip" → Example: "10.10.10.10"
  • "geo.countryCode" → Example: NL
  • "geo.countryName" → Example: Netherlands
  • "geo.regionCode" → Example: NH
  • "geo.regionName" → Example: North Holland
  • "geo.zipCode" → Example: "1000"
  • "geo.timeZone" → Example: Europe/Amsterdam
  • "geo.latitude" → Example: 52.35
  • "geo.longitude" → Example: 4.9167
  • "geo.hemisphere" → Example: "southern"
  • "geo.currency" → Example: "USD"

TIME & DATE

  • "time.date"  → Example: "2017-11-17T14:51:00+01:00"
  • "time.hour" → Example: 14
  • "time.minute" → Example: 51
  • "time.day" → Example: 17
  • "time.month" → Example: 11
  • "time.year" → Example: 2017
  • "time.dayOfWeek" → Example: Monday
  • "time.timeOfDay" → Example: afternoon
  • "time.timeOfYear" → Example: summer

BEHAVIOR

  • "behavior.referer" → Example: https://facebook.com
  • "behavior.returningVisitor" → Example: "true"

PARAMETERS:

  • "parameters.utm_source" → Example: Google
  • "parameters.utm_medium" → Example: CPC
  • "parameters.utm_campaign" → Example: spring-sale
  • "parameters.utm_content" → Example: spring-dresses
  • "parameters.utm_term" → Example: red-dress

CUSTOM PARAMETERS:

  • "parameters.xxx" → Replace xxx with any query parameter you send through via the URL.

    Example:
    Let's say you have a fitness training website. You ask your visitors to answer one question - What is your goal? A) lose weight B) gain muscle
    You can store their answer in the URL and use it to for dynamic injection.


    URL:
    fitness.com?goal=weight
    Dynamic Content Insertion:
    if (Txt.get('goal') == 'weight') {
      Txt.set('dynamic.placeholder', 'We will help you lose weight');
    } else {
    Txt.set('dynamic.placeholder', 'We will help you gain muscle');
    }
Did this answer your question?