_satellite.getVar("window.*")

An undocumented feature of _satellite.getVar was the ability to use it to reference any object existing at global scope. The function would essentially check the argument to see if it started with "window." and if it did, the code would evaluate JS variables instead of DTM data elements. This was really nice if you wanted to know the value of window.digitalData.page.pageInfo.pageName because a single call to getVar would return the value or "undefined" if any part of that deeply nested structure did not exist.

Sadly, this little gem did not make it into Launch.

Remedy:

1) Create Data Elements using the Core > JavaScript Variable data element type. Reference these data elements using _satellite.getVar().

2) If you would rather have a direct (function-for-function) replacement, include a function like this (or similar) in your implementation. You might have this function returned by a Core > Custom Code data element.

function getNestedProp(path) {
if (path.match(/^window\./)) {
var resolved = path.split(".").reduce(function(acc, key, idx, arr) {
if (acc === "window" && window[key]) {
return window[key];
} else if (acc[key]) {
return acc[key];
} else {
return {};
}
})
if (Object.keys(resolved).length=== 0){
return "";
} else {
return resolved;
}
} else {
console.error("getNestedProp(path):", "path must begin with 'window.'");
return;
}
}

Then call this function in place of _satellite.getVar("window.*").

‚Äč