Data Element Custom Script not working as Data Element but works in console?
I've been trying to extract individual key value pairs from a query string....we've been seeing UTM parameters in our Full Page URLs reports in AA. Right now we're using the cmpid value for campaigns, so I can't replace this value with utm
Example:
Query String (we see the full string):utm_source=google&utm_medium=organic&utm_campaign=local&utm_content=downtown
I am trying to extract each utm parameter separately (in the below example, the DE is added to a Page Load rule and in AA we'd see "Custom Conversion > prop74 > UTM Source > google)
UTM Source Data Element
var params = {};
if (location.search) {
var parts = location.search.substring(1).split('&');
for (var i = 0; i < parts.length; i++) {
var nv = parts[i].split('=');
if (!nv[0]) continue;
params[nv[0]] = nv[1] || true;
}
var utm_source = params.utm_source;
This is set to a page load rule - mapped back to either eVar74 or prop74
I'm seeing the output when I test this code in the console - but it doesn't work in DTM...
Any help is REALLY appreciated!