Substitution of Data from the Site in Widgets

Reteno can use data from your website to personalize widget text and prefill form fields.

Five data types are available for personalizing text with Merge Tags:

  • Data layer is a structure that stores data about user actions on the website. For example, a widget can display an offer for the product category that a visitor is currently viewing.
  • URL query parameter is a key=value pair in the part of a URL after ?, for example, https://shop.com/product/123?coupon=PARTNER25. You can use it to pass promo codes, traffic sources, and other values.
  • JavaScript variable is a variable in the global scope of the page's JavaScript code. It can pass values such as cart total, subscription status, or loyalty tier.
  • Cookie stores data in browser cookies that belong to your domain. Cookie values can personalize widgets based on referral source, login status, or previous user actions and persist across sessions.
  • Local storage stores data in your domain's browser storage. Its values also persist across page reloads but, unlike cookies, are not sent to the server with every request. Local storage is suitable for storing page-view counts, completed actions, user preferences, and other client-side data.

You can use these values in two ways:

  • Merge Tags insert data into headings, descriptions, buttons, and other text elements. All five data types are available for Merge Tags.
  • Prefill inserts values into form fields so visitors do not have to enter information that is already known. All five data types listed above are available for prefill. You can also select Static field — a contact field in Reteno, such as Email.
šŸ“˜

Note

The same data types — Data layer, JavaScript variable, Cookie, and Local storage — are also available as conditions in widget calling rules. Use them to control when and to whom the widget appears, not just to personalize its text.

Finding Data in the Data Layer on Your Website

Open Developer Tools in your browser: press Ctrl+Shift+I on Windows or Cmd+Option+I on macOS. You can also right-click the page and select Inspect.

  1. Open the Console tab.
  2. Enter dataLayer and press Enter.
  3. Expand the list to review the Data layer structure and find the required event or parameter.
Browser Developer Tools Console tab showing the expanded dataLayer array with event objects

Using URL Query Parameters

Add the required parameter to a link to your website, for example, https://shop.com/product/123?coupon=PARTNER25. When a visitor follows the link, you can use the parameter value in widget text or a form field. For example: Enter code PARTNER25 — the 25% discount will be applied automatically.

To pass several values, separate the parameters with &:

https://shop.com/product/123?coupon=PARTNER25&source=partner

Setting Up JavaScript Variables on Your Site

To pass variable values to Reteno, add the script:

  • directly to your website code;
  • or to a Custom HTML tag in Google Tag Manager (more).

Script format:

<script>
  reteno('addVariables', { variableName: value });
</script>

For example, to pass the subscription status:

<script>
  reteno('addVariables', { subscribed: false });
</script>

You can also pass several variables at once:

<script>
  reteno('addVariables', {
    user_age: 25,
    user_status: 'vip'
  });
</script>

Values are stored until the page is reloaded or the visitor navigates to another page, similar to Data layer data.

Adding Merge Tags to Widget Text

  1. Go to Site → Widgets, then open an existing widget or create a new one.
Analytics
  1. Select the text you want to personalize, click Merge tag, and choose Data layer, URL query parameter, JavaScript variable, Cookie, or Local storage.
Widget editor with a selected text field and a Merge tag dropdown open, showing Data layer, URL query parameter, JavaScript variable, Cookie, and Local storage options
  1. Configure the Merge Tag according to the selected source.

Data Layer

  • Data layer event — specify the event name.
  • Path to variable — enter the exact path to the required value in the Data layer.
  • Example value — add a sample value to preview the widget in the editor.
Merge tag panel for a Data layer type with Data layer event, Path to variable, and Example value fields filled in
šŸ“˜

Note

  • The eventName field is optional and only required if your Data layer follows Google's recommended structure. Even if your events lack names, the system will locate the necessary parameters based on the path format, such as ecommerce.items.0.price.
  • If multiple similar parameters exist in the Data layer, or if the Data layer is duplicated, the system will use the latest instance.
  • Ensure you enter parameter names exactly as they appear in the Data layer so the system recognizes them. Additionally, parameter names must meet Google's requirements.
Browser console showing an expanded dataLayer entry with ecommerce items array fields including item_category, item_name, and price, and the view_item event name highlighted

URL Query Parameter

Enter the parameter name and an example value to preview the widget.

Merge tag panel for a URL query parameter type with the parameter name and example value fields filled in

JavaScript Variable

Enter the variable name and an example value to preview the widget.

Merge tag panel for a JavaScript variable type with the variable name field empty and an example value filled in

Cookie

Enter the cookie name and an example value to preview the widget.

Merge tag panel for a Cookie type with the cookie name field empty and an example value filled in
šŸ“˜

Note

  • Reteno can only read cookies from your domain — third-party cookies are not accessible.
  • Cookies with the HttpOnly attribute are unavailable to JavaScript, so they cannot be used in Merge Tags or for prefill.

Local Storage

Enter the Local storage key and an example value to preview the widget.

Merge tag panel for a Local storage type with the storage key field empty and an example value filled in

Prefilling Form Fields

Prefill inserts information that is already known about a visitor into a form. For example, you can add the value of the Email contact field from Reteno, a first name from the Data layer, an email address from a URL parameter, or a phone number from a cookie. The visitor only needs to check the value and submit the form.

Prefill is available for the following fields:

  • Email;
  • Phone;
  • First Name;
  • Last Name;
  • text fields.

The following options are available:

  • Static field — a contact field in Reteno, such as Email;
  • URL query parameter — the value of a URL parameter;
  • JavaScript variable — the value of a JavaScript variable;
  • Local storage — a value from browser storage;
  • Cookie — a value from a cookie that belongs to your domain;
  • Data layer event — a parameter value from a Data layer event.

To configure prefill:

  1. Open the widget in the editor and select the required form field.
  2. Enable prefill in the field settings.
Autofill
  1. Select one of the available options.
  2. Complete the settings displayed for the selected option:
  • select the required Reteno contact field for Static field, for example, Email;
  • enter the parameter name for URL query parameter;
  • enter the variable name for JavaScript variable;
  • enter the key for Local storage;
  • enter the cookie name for Cookie;
  • specify the event and path to the required value for Data layer event.
  1. Save the widget and test prefill on your website with sample data.

If the system cannot find a value in the selected source or contact field, the field is not prefilled. It displays its configured placeholder, and the visitor can enter the value manually.

šŸ“˜

Recommendations

  • Make sure the value matches the field format. For example, pass a valid email address to Email and a phone number in a format supported by the form to Phone.
  • Do not pass sensitive data in URL parameters. These values may be stored in browser history, server logs, and analytics systems.
  • Use cookies in accordance with your privacy policy and consent settings.

Prefill Examples

OptionExample SetupResult
Static fieldContact field EmailThe form displays the value of the contact's Email field.
URL query parameterParameter firstName in https://app.com/offer?firstName=OlenaThe First Name field displays Olena.
JavaScript variableVariable customerNameThe field displays the current variable value.
Local storageKey customer_phoneThe form uses the phone number stored under this key.
CookieCookie user_emailThe Email field displays the cookie value.
Data layer eventEvent and path user.firstNameThe First Name field displays the value from the Data layer.

When values differ between visitors, test the widget with several sample datasets.

Data Layer Use Cases

Displaying the Viewed Product Category in a Widget

  • Scenario:

A user browses products in a specific category on your website. You want to grab their attention by displaying a pop-up offering a 10% discount if they purchase two items from the category they are currently viewing.

  • Setup:
  1. Data layer event: Use the view_item event to retrieve data.
Merge tag panel for a Data layer type with the Data layer event field set to view_item
  1. Path to variable: Open Developer Tools, locate the view_item event in the Data layer.
Browser console showing the expanded dataLayer array with the view_item event highlighted

Define a property containing product category information (in our example, item_category).

Browser console expanded dataLayer entry with the item_category property highlighted inside the ecommerce items array

Right-click on the line containing item_category, and copy its property path.

Browser console right-click context menu on the item_category property showing the Copy property path option

Paste it into the Path to variable field. Remove any array indices at the beginning (e.g., 13 in our example).

Merge tag panel for a Data layer type with the Path to variable field showing the ecommerce.items[0].item_category path with a leading array index crossed out
  1. Example value: Enter a sample category (e.g., Jewellery) in the Example value field to preview how the widget will look.
Merge tag panel for a Data layer type with the Example value field set to Jewellery

Abandoned Cart Reminder with Dynamic Product Information

  • Scenario:

A user adds an item to the cart but does not proceed to checkout within a certain period. This behavior suggests hesitation or distraction. To re-engage them, you can trigger a pop-up reminding them to complete the purchase, displaying the product names in their cart along with a special incentive.

  • Setup:
  1. Data layer event: add_to_cart

  2. Path to variable: ecommerce.items[0].item_name

Browser console showing an add_to_cart event's ecommerce items array with the item_name property highlighted
  1. Example value: Item name
Merge tag panel for a Data layer type with Data layer event set to add_to_cart, Path to variable set to ecommerce.items[0].item_name, and Example value set to Item name

After saving the pop-up, configure its calling rules.

Widget calling rules with Rule-based enabled, Display frequency set to One time per 1 days, and When to stop displaying set to After subscription

Increasing the Total Order Value

  • Scenario:

To encourage customers to increase their cart total, you can display a dynamic message like: Spend $300 to get a 10% discount. Your current cart total is N. Here, N is dynamically replaced with the current cart value.

  • Setup:
  1. Data layer event: view_cart

  2. Path to variable: checkout.total_value

Browser console showing a view_cart event with the checkout object's total_value property highlighted
  1. Example value: Total value
Merge tag panel for a Data layer type with Data layer event set to view_cart, Path to variable set to checkout.total_value, and Example value set to Total value

JavaScript Variable Use Cases

Personalizing Offers Based on Loyalty Tier

  • Scenario:

You want to show VIP customers a pop-up with an exclusive offer, while other visitors see a standard promotion. The loyalty tier is available in your system after the user logs in.

  • Setup:
  1. Pass the loyalty tier via a JS variable:
<script>
  reteno('addVariables', { loyalty_tier: 'vip' });
</script>
  1. Use the variable as a Merge Tag in the pop-up text: "As a {{loyalty_tier}} program member, here's a special offer just for you."

Or create a separate pop-up for VIP customers and set the condition in calling rules: JavaScript variable loyalty_tier equals vip.

Cookie Use Cases

Personalized Welcome for Visitors from a Partner Site

  • Scenario:

A visitor arrives at your site via a referral link from a partner. You want to show them a personalized pop-up with an exclusive promo code or special welcome message on their first visit.

  • Setup:

Cookie name: referral, example value: partner123.

The Merge Tag will substitute the value into the pop-up text: "Welcome from {{referral}}! Here's a special 15% discount just for you."

Targeting by Viewed Categories

  • Scenario:

Your site stores the product categories a user has browsed in a cookie. You want to show a relevant pop-up — for example, an accessories offer for the category that interested the visitor.

  • Setup:

Cookie name: lastViewedCategory, example value: Shoes.

The Merge Tag will substitute the value into the pop-up text: "New {{lastViewedCategory}} collection is here!"

Local Storage Use Cases

Personal Recommendation Based on Quiz Results

  • Scenario:

Your site has a product configurator or quiz. After completion, the result is stored in Local storage. You want to show a pop-up with a personal recommendation — immediately or during the next visit.

  • Setup:

Local storage key: recommended_product, example value: Running shoes.

The Merge Tag will substitute the value into the pop-up text: "Based on your answers, {{recommended_product}} are the right fit for you. Here's 10% off your first order."

Bonus Points Reminder

  • Scenario:

After login, your site stores the user's bonus point balance in Local storage. You want to remind them in a pop-up to encourage a purchase.

  • Setup:

Local storage key: bonus_points, example value: 350.

The Merge Tag will substitute the value into the pop-up text: "You have {{bonus_points}} bonus points — use them before the end of the month."

Potential Issues

Merge Tags

IssueOutcome
Missing Data layerThe pop-up will not display
Invalid pathAn empty or incorrect path will prevent the system from retrieving the required data
Path leads to an object or an array of objectsThe pop-up will not display
Path leads to an array of primitive values (e.g., numbers or strings)Values will be displayed separated by commas and spaces
Parameter missing in URLThe pop-up will not display
JS variable not definedThe pop-up will not display
Cookie is inaccessible (HttpOnly or third-party domain)The pop-up will not display
Local storage key does not exist or is emptyThe pop-up will not display

Prefill

If the selected source or contact field does not contain the required value, the field remains available for manual input and displays its configured placeholder.



Did this page help you?