Add variables to links
You can add variables to links in your text messages to send your subscribers to unique URLs. For example, you can use variables for enhanced link tracking, send subscribers to personalized landing pages, and take better advantage of certain apps.
Follow these steps to add variables to a link:
- Create or edit a campaign or journey message.
- In the message editor, click to add a new shortlink or click on an existing shortlink.
A popup window opens. - In the Original URL field, click .
A popup window opens.
- Select a Variable, then enter a Default value. While not required, we recommend entering a default value to ensure that subscribers go to an appropriate URL even if they don’t have values for your selected variable. See the example in the paragraph below for more information.
- Click Insert variable.
- Click Update shortlink.
There are many ways to use variables in links. For example, imagine that you assign a custom attribute to subscribers based on the kinds of products they’re most interested in. You also set up separate landing pages for each kind of product. The URL you add to your link might look something like this:
https://www.yoursite.com/{{subscriber.custom['Product category'] | default: 'outerwear'}}
In this example, a subscriber with a custom attribute value of shoes could be directed to a landing page focused on shoes. Another subscriber who doesn’t have a custom attribute could be directed to a landing page about outerwear, since that’s the variable’s default value.
Here are a few other examples of ways to use variables in links:
- Enhanced tracking: Track metrics like where subscribers came from or which sign-up unit they used. This information can help you analyze user behavior and make data-driven decisions.
- Auto-login or soft login: Direct users to personalized pages based on a unique ID where they can be automatically logged in across devices, facilitated by cookies.
- Non-Shopify cart links: If your brand isn’t on Shopify, you may be able to use variables in links to drive users to their unique shopping carts.
- Dynamic images: Display images of previously purchased items by uploading unique URLs for each customer as attributes and then substituting the custom attribute variable into an <img> HTML string. For example, you can prepare unique IDs representing items that subscribers have purchased. In Attentive, you can upload these IDs to a custom attribute for each subscriber. You can then create a dynamic image URL by inserting the variable for the custom attribute in the Url field when inserting an image in the email builder. That URL might look something like the following: https://orchardstcoffee.com/cdn/shop/products/Nitro_CB_Oat_533x.jpg?v={{subscriber.custom['imageID'] | default: ''}}
- Integration support: Macros can strengthen existing app integrations by enabling additional features, like dynamic content or product recommendations.
- Advanced coupon assignment: If your brand isn’t on Shopify, you may be able to use a coupon variable in links in order to auto-apply coupons.