Understanding and Effectively Using the _satellite.setVar() Function in Adobe Launch


Introduction

In the world of digital marketing and web analytics, Adobe Launch (Data Collection) has become an essential tool for marketers and developers. One of the more advanced features of DTM is the use of the _satellite.setVar() function, which allows users to dynamically set the values of Data Elements during runtime. However, many users encounter challenges when trying to manipulate pre-defined Data Elements using this function. In this post, we’ll explore the intricacies of the _satellite.setVar() function, including how it works, why it may not behave as expected, and best practices for effectively using it within your DTM implementation.


Problem Statement or Background

Adobe DTM provides a powerful interface for managing tags and Data Elements on your website. Data Elements, in particular, are foundational to the DTM ecosystem, acting as variables that store and deliver data to various tags and rules. However, users often run into issues when they attempt to set the values of pre-defined Data Elements dynamically using the _satellite.setVar() function. This can lead to confusion, as the expected outcome—updating the value of a Data Element—doesn’t occur as anticipated.

The root of the problem lies in understanding how DTM handles Data Elements defined within the interface compared to those defined on-the-fly using _satellite.setVar(). This blog post aims to clarify these differences and provide a detailed guide on how to use the _satellite.setVar() function effectively.


Key Concepts or Terminology

Before diving into the technical details, it’s essential to understand some key concepts:

  • Adobe DTM (Dynamic Tag Management): A tag management system that allows marketers and developers to manage and deploy tags, JavaScript, and other web technologies without modifying the underlying code.
  • Data Elements: Variables within DTM that store data and can be used across various rules and tags. They can be predefined through the DTM interface or created dynamically using JavaScript.
  • _satellite.setVar(): A JavaScript function in Adobe DTM that allows users to set the value of a Data Element dynamically during runtime.
  • _satellite.getVar(): A corresponding function that retrieves the value of a Data Element.

Detailed Explanation

The Core of the Issue: Data Element Namespaces

When working with Data Elements in Adobe DTM, it’s important to recognize that Data Elements defined within the interface have a different namespace and scope than those defined on-the-fly using the _satellite.setVar() function.

1. Data Elements Defined in the Interface

Data Elements that are predefined within the DTM interface are stored within the _satellite.dataElements object. These are evaluated and referenced based on their configuration, such as a JavaScript Object, CSS Selector, or Custom Code.

When you use the _satellite.getVar() function to retrieve a Data Element’s value, DTM first looks in the _satellite.dataElements object. If the Data Element is found, DTM evaluates it according to its configuration and returns the value.

2. Data Elements Defined On-the-Fly

On the other hand, Data Elements that are defined dynamically using the _satellite.setVar() function are stored within the _satellite.data.customVars object. This means that they are evaluated and stored separately from the predefined Data Elements.

When you use _satellite.getVar() to retrieve a value, if the Data Element is not found in _satellite.dataElements or as a built-in Data Element (such as hostname), DTM then checks _satellite.data.customVars to see if the Data Element was defined using _satellite.setVar().

Why _satellite.setVar() Doesn’t Work on Predefined Data Elements

Given this distinction in namespaces, you cannot use _satellite.setVar() to update the value of a Data Element that has been predefined within the DTM interface. Attempting to do so will not produce the expected result, as these Data Elements are evaluated based on their initial configuration and not from dynamic assignments.

For example:

javascriptCopy code_satellite.getVar('PageName'); // Returns the value from _satellite.dataElements

_satellite.setVar('PageName', 'test'); // Sets a new value in _satellite.data.customVars

_satellite.getVar('PageName'); // Still returns the original value from _satellite.dataElements

As seen in the example above, after setting a new value using _satellite.setVar(), retrieving the value still returns the original value from _satellite.dataElements.


Step by Step Guide

Here’s a step-by-step guide on how to effectively use the _satellite.setVar() function within your Adobe DTM setup:

Step 1: Understand the Purpose

Before using _satellite.setVar(), ensure that you understand its purpose. This function should be used to set the value of a Data Element on-the-fly, primarily for custom Data Elements that are not predefined in the DTM interface.

Step 2: Create a Data Element Dynamically

If you need to create a Data Element dynamically, you can use _satellite.setVar() to store the value. For example:

javascriptCopy code_satellite.setVar('CustomElement', 'Value');

This will store the Data Element in _satellite.data.customVars.

Step 3: Retrieve the Custom Data Element

To retrieve the value of the dynamically created Data Element, use _satellite.getVar():

javascriptCopy codevar myValue = _satellite.getVar('CustomElement');

Step 4: Avoid Name Conflicts

To prevent conflicts between predefined and dynamically created Data Elements, always use unique names for custom Data Elements created with _satellite.setVar(). This will help avoid any unexpected behaviors or values being returned.

Step 5: Debugging

If you encounter issues, use the browser’s console to inspect the _satellite.dataElements and _satellite.data.customVars objects to verify where your Data Elements are stored and what values they hold.


Best Practices or Tips

  • Avoid Using _satellite.setVar() on Predefined Elements: As discussed, attempting to use _satellite.setVar() on Data Elements defined in the DTM interface will not work as expected. Instead, rely on the initial configuration of those Data Elements.
  • Use Unique Names: To avoid conflicts, always use unique names for custom Data Elements created with _satellite.setVar().
  • Debugging Techniques: Regularly use console logging to check the contents of _satellite.dataElements and _satellite.data.customVars to ensure that your Data Elements are being set and retrieved correctly.
  • Understand Built-In Data Elements: Familiarize yourself with the built-in Data Elements that DTM provides out of the box, such as hostname, and understand how they interact with custom Data Elements.

Case Studies or Examples

Example 1: Setting a Dynamic Page Title

Imagine you want to dynamically set a page title based on user actions. You could use _satellite.setVar() to create a custom Data Element called DynamicPageTitle and set its value based on user interactions:

javascriptCopy code_satellite.setVar('DynamicPageTitle', 'New Title Based on User Action');

Later, you can retrieve this value and use it in another rule:

javascriptCopy codevar pageTitle = _satellite.getVar('DynamicPageTitle');
console.log(pageTitle); // Outputs: "New Title Based on User Action"

Example 2: Custom Data Element for Special Promotions

Suppose you want to track special promotions only for specific users. You can dynamically create a Data Element:

javascriptCopy code_satellite.setVar('SpecialPromo', 'Promo123');

You can then use this Data Element in your analytics tracking to see which users were shown this promotion.


Troubleshooting and FAQ

Q: Why is my Data Element value not updating when using _satellite.setVar()?

A: If the Data Element was predefined in the DTM interface, it won’t be updated using _satellite.setVar(). Ensure you are using _satellite.setVar() on custom Data Elements only.

Q: Can I use the same name for Data Elements in the interface and custom ones created with _satellite.setVar()?

A: It’s best to avoid using the same name, as this can lead to unexpected behavior. Always use unique names for dynamically created Data Elements.

Q: How can I debug issues with my Data Elements?

A: Use the browser console to inspect _satellite.dataElements and _satellite.data.customVars. This will help you see where your Data Elements are stored and what values they hold.


Conclusion

Understanding the nuances of how Adobe DTM handles Data Elements is crucial for effectively managing your digital marketing efforts. The _satellite.setVar() function is a powerful tool, but it must be used correctly and within the appropriate context. By following the guidelines and best practices outlined in this post, you can avoid common pitfalls and make the most of this functionality in your DTM implementation.

Leave a Reply

Your email address will not be published. Required fields are marked *