Overview
This guide will walk you through how to test data persistence across an entire user journey using ObservePoint Journeys and Tag & Variable Rules.
The most common use case is testing if campaign tracking codes or unique identifiers (e.g. session ids, visitor ids, etc.) persist until an important conversion event.
Note: This solution works if the data you want to verify persists can be referenced in the developer console e.g. data layer, query parameters, SDK, or other data object.
Implementation
Configuring the Journey
To begin, be sure to become familiar with how to create a Journey.
Next verify that you have localStorage or sessionStorage configured as a Data Layer in your account. This ensures that in each action in a Journey, ObservePoint will report all values currently stored in those objects. This is critical because in either the local or session storage, we will store the data you want to be sure persists.
Every Journey begins with a Navigate To
action. After this action, you will need to add an Execute JavaScript
action that stores the data you want to verify persists throughout the Journey.
Example 1: Query Parameters
// Loop through all query parameters in the current URL
for (const [key, value] of new URLSearchParams(location.search)) {
// Store each parameter using "qp_" + key as the localStorage key
localStorage.setItem(`qp_${key}`, decodeURIComponent(value));
}
In this example, each query parameter is stored in the localStorage object with a prefix of qp_
to ensure it doesn't collide with an existing variable with the same name.
Example 2: Data Layer Variable
// Store the sessionId captured by the data layer in local storage.
localStorage.setItem(`dl_sessionId`, dataLayer.sessionId);
In this example, the data layer variable sessionId
is stored in the localStorage object with a prefix of dl_
to ensure it doesn't collide with an existing variable with the same name.
These examples can be modified as needed, but the principle is that you need to store the value of the variable you want to check persistence for in the localStorage or sessionStorage objects.
Next you need to add the rest of the actions in the Journey that produce the conversion event you want to test.
After you finish configuring the actions, run the Journey to test and verify that the actions run as expected.
Creating & Applying the Rule
Now that the Journey is configured, you need to create a Tag & Variable Rule that fails if the conversion event tag variable contains a value that doesn't match the value stored in localStorage or sessionStorage.
Example 1: Rule for stored Query Parameter
Example 2: Rule for stored Data Layer variable
It is critical that you apply this rule to the right action. It needs to be the action where you expect the conversion event to fire (e.g. form submission, order confirmation) and contain the same variable data that you stored in the 2nd action.