SiteData is our signature targeting option that helps you show or hide campaigns based on any data you have in your data layer about a visitor, such as cart value, products viewed, search terms, and so on.
In addition to the targeting option and trigger, you can also use the information in your SiteData storage as merge tags in your campaigns’ text fields and input fields.
Merge tags help you personalize your campaigns for each visitor, prefill your input fields, and collect richer lead data.
But, first things first.
Prefer to see it in action? Watch this video by Kristian, where he explains how SiteData merge tags work and how you can set it up in Google Tag Manager:
How SiteData Merge Tags Work
Whatever data you’re sending to Onsite SiteData, you can use it as a merge tag in your campaigns.
💡 Read this article to learn how to send data to SiteData.
If you’re using Google Tag Manager, your variables might look like this:
GTM Variable is what your variable is called in Google Tag Manager and must be written exactly the same way as everywhere else in your GTM account.
SiteData Variable is the name you want to give to your variable while sending it to us. You’ll use this variable name, such as “Total Basket Value” or “User ID,” in your Onsite campaign.
Fallback Value for Merge Tags
If the value of your SiteData merge tag is empty for a visitor (i.e. you don't have the data,) we won't show any value. For example, if you use a merge tag for first name “Hello name,” they'll see it as "Hello".
If you want to set a fallback value, instead, you can do this in your tag manager. (For example, you can set a default version as “Hello there.”)
To do that, create a new tag and add a default value in the following format:
So, if you want your fallback value to be "there," simply write "there" to the field shown above.
“Your SiteData Variable” must be written in the exact same way as you send it to SiteData.
🚨 Important: You should send the above tag (with default value) to SiteData as early as possible, before you load the Drip script. Then, if an event or trigger (such as Add to Cart) is triggered and aGTM Variable is sent to SiteData, this variable will overwrite the default value.
How to Use Merge Tags in Campaigns
Simply follow this format to use SiteData merge tags in your campaigns:
{{SiteData:Your SiteData Variable}}
For example, your merge tag might look like this:
{{SiteData:Total Basket Value}}
No matter where you want to use merge tags, all you need to do is to write them in the format above. 😌
Merge Tags in Text Fields
By using SiteData merge tags in text fields, you can personalize your campaigns for each visitor.
For example, if you have a variable in your data layer that checks the value of items in a visitor’s cart and calculates what’s left until free shipping, you can use this variable as a merge tag in your campaigns:
Or you can welcome your customers with their first name when they log in to your site:
Merge Tags in Input Fields
By using merge tags, you can prefill your campaign input fields with the data you already have in your SiteData storage.
For example, if you already have a first name or email address for a visitor, you can pre-populate those input fields in a campaign.
To do this, click the input field you want to prefill and use the option “Change Value Attribute."
Write your variable as in the field and use the variable you want to get from SiteData, such as name, gender, country, email address, and so on.
This way, you won’t ask the same question over and over, and make it easier for visitors to fill out your forms. 🚀
Advanced SiteData Functions
You can also use more advanced functions, such as logic, string concatenation, and math functions with SiteData.
One of the best use cases of this functionality is calculating the difference between your free shipping threshold and a visitor's cart value.
Say you offer free shipping for orders above €500 and want to nudge shoppers when they add an item for less than that amount to their cart.
If you send the cart value variable to our SiteData storage, you can then calculate the difference between €500 and the visitor’s cart value with this formula:
SUM(SITEDATA(cart_total), - 500)*-1
Note: Remember to replace “cart_total” with the name of your SiteData variable.
You can use this formula in your campaign’s text fields like this:
When a visitor adds, for instance, items worth €150 to their cart, the campaign will calculate the difference automatically:
Note: Be aware that platforms like Shopify might send the cart value variable in a different format. Reach out to our Support team if you need help with this advanced function. 👋