You can use the Connected Content feature to fetch and display data from an external JSON file hosted on your server at the moment a message is sent. This ensures the information is always up-to-date without needing to update attributes for each user individually and frequently.
This method is supported for various channels, including push notifications, emails, and in-app messages.
Here's how it works:
Prepare Your Data Source:
- Host a JSON file on your server that is publicly accessible via a URL. This file should contain the data you want to display (e.g., product details, prices in different currencies, stock levels).
- Example JSON structure for product prices in different currencies:
{ "product_123": { "name": "Awesome Gadget", "prices": { "USD": 29.99, "EUR": 27.99, "GBP": 25.99 }, "stock_available": true }, "product_456": { "name": "Super Tool", "prices": { "USD": 49.99, "EUR": 46.99, "GBP": 44.99 }, "stock_available": false } }
Use the
connected_content
Tag in Your Message Template:- In your message template (for push, email, or in-app), use the Liquid tag
{% connected_content %}
to fetch the JSON data from your URL. - Save the fetched data into a variable (e.g.,
external_data
).
Replace{% connected_content https://yourserver.com/path/to/your-data.json :save external_data %}
https://yourserver.com/path/to/your-data.json
with the actual URL of your JSON file.
- In your message template (for push, email, or in-app), use the Liquid tag
Display the Data Using Liquid Templating:
- Access the data from the
external_data
variable within your message content using Liquid syntax. - For example, to display the name and USD price for "Awesome Gadget":
Check out the {{ external_data.product_123.name }}! Price: ${{ external_data.product_123.prices.USD }}
- Access the data from the
Personalize with User Tags (Optional):
- To display data tailored to individual users (e.g., price in their preferred currency), you can use user tags within your Liquid template.
- Suppose you have a user tag named
preferred_currency
(e.g., its value could be "USD", "EUR"). You can use this tag to dynamically select the correct price:
Note: The exact syntax for accessing user tags in Liquid (e.g.,{% comment %} Assuming 'user_tags.preferred_currency' holds the user's currency preference, e.g., "EUR" {% endcomment %} Hi {{ user_tags.first_name | default: "there" }}, The price for {{ external_data.product_123.name }} in your preferred currency is: {{ external_data.product_123.prices[user_tags.preferred_currency] }}
user_tags.preferred_currency
,profile.preferred_currency
, or simplypreferred_currency
) may depend on your specific platform setup. Please refer to your platform's Liquid templating documentation for the correct syntax for user tags.
By using Connected Content, you maintain your dynamic data (like prices and currencies) on your server, and it's fetched fresh each time a message is prepared for sending, ensuring accuracy and relevance without mass daily updates to user profiles.
For more detailed information and advanced examples, please refer to the official documentation on Personalization with Liquid Templates, specifically the section on Connected Content (you can typically find this in your service provider's developer documentation, for example: https://docs.pushwoosh.com/developer/guides/personalization/liquid-templates/#connected-content
).
Comments
0 comments
Please sign in to leave a comment.