Skip to main content
All CollectionsObservePoint Custom Tag
OP Custom Tag - Query parameter mapping
OP Custom Tag - Query parameter mapping
Luiza Gircoveanu avatar
Written by Luiza Gircoveanu
Updated over 2 weeks ago

Overview

This custom tag describes the steps and code needed to set up at least a query parameter mapping and attribution validation for Journeys.

The problem that this solution solves is described below.

Most websites and marketing landing pages operate in the following expected sequence of events, regarding the handling and processing of attribution data:

  1. User navigates to or clicks on an ad link (e.g. paid search landing page)

  2. User interacts with the website or page until they come up to some conversion event (e.g. form fill)

  3. Upon triggering the conversion event (e.g. clicking "Submit"), an analytics tag is expect to fire, and is expected to contain attribution data from the original ad URL query parameters

Sometimes errors occur, somewhere between the first step to the last step, where attribution data is lost or mishandled. This can cause missing or inaccurate data for those analyzing campaign and paid media performance.

The following instructions can help you set up a Journey that tests this process, to ensure that your attribution data is being properly collected, on an ongoing and automated fashion. If this is your first time creating Journeys and you'd like to create this Journey on your own, you can start with this documentation, or if you'd prefer to use the Journey Support team, you can do so while still referencing the below instructions, as a means to better understand and articulate your requirements to Journey Support.

Journey Actions

Create a new Journey, and configure the following Journey Actions:

  • Action 1: Navigate to a landing page URL with query parameters

  • Action 2: Capture query params on the second Action of a Journey, and add them to localStorage - you don't need to edit this code - rather, just copy it and paste it into an "Execute Javascript" Action

let urlParams = {}

window.location.href.split('?')[1].split('&').forEach(
(utm) => urlParams[utm.split('=')[0]] = utm.split('=')[1]
)

localStorage['savedQueryParams'] = JSON.stringify(urlParams)

Next, create as many Actions as are needed to complete the conversion event.

  • On the final Action (the one that triggers a conversion), you will need to make this Action an "Execute JavaScript Action", and perform whatever automation is necessary to trigger the conversion (e.g. click "Submit"). Feel free to use this help doc to understand what JavaScript you might need. In the same Execute JavaScript Action, paste the following code to retrieve the original landing page query params. This will add the query params to an ObservePoint Custom Tag. We will use this later to validate the proper handling of your original landing page URL query params.

let originalQueryParams = JSON.parse(localStorage.savedQueryParams)

function opReqGetAsync(paramObject, acct, callback) {
var baseURL = window.location.protocol + "//" + window.location.hostname + "/observepointcustomtag?acct=" + acct;
var opReq = new XMLHttpRequest();
opReq.onreadystatechange = function() {
if (opReq.readyState === 4 && opReq.status === 200) {
callback(opReq.responseText);
}
};
opReq.open("POST", baseURL, true);
opReq.send(JSON.stringify(paramObject));
}
opReqGetAsync(originalQueryParams, 'Original Page Query Parameters');

Rule Setup

Create a Rule that compares the original page query params (from the OP Custom Tag) to your analytics tag payload. This should be the tag on the final conversion event, where you expect to see your query params. Here is an example of what the Rule might look like, but keep in mind that your testing needs and expected data processing results may necessitate a different Rule configuration. Apply the Rule to the final Action of your Journey, and subscribe to the Rule in the email address field.

You should now receive an email notification if the Rule fails, which would indicate that the most recent Journey run identified a failure in in your attribution data collection, at least as the failure was observable on the browser/client side.

Did this answer your question?