Expand my Community achievements bar.

SOLVED

s.campaign showing null values

Avatar

Level 4

I have s.campagin implemented in Adobe Launch extension code for Adobe Analytics for s.campaign . When there are utm values , s.campaign populates fine, but when there are no values it shows in s.campaign it shows null values

 

e.g. s.campaign: null|null|null|null

 

How do I remove the null not showing in the debugger and in reporting?

 

 

if (!s.campaign) {
    s._utm_campaign = s.getQueryParam('utm_campaign');
    s._utm_source = s.getQueryParam('utm_source');
    s._utm_medium = s.getQueryParam('utm_medium');
    s._utm_term = s.getQueryParam('utm_term');
    s._utm_content = s.getQueryParam('utm_content');
    s.campaign = s._utm_source + "|" + s._utm_medium + "|" + s._utm_campaign + "|" + s._utm_term + "|" + s._utm_content;
    if (s.campaign === "||||") { s.campaign = "" }
}

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Try this:

if (!s.campaign) {
    s._utm_campaign = s.getQueryParam('utm_campaign');
    s._utm_source = s.getQueryParam('utm_source');
    s._utm_medium = s.getQueryParam('utm_medium');
    s._utm_term = s.getQueryParam('utm_term');
    s._utm_content = s.getQueryParam('utm_content');
    s.campaign = s._utm_source + "|" + s._utm_medium + "|" + s._utm_campaign + "|" + s._utm_term + "|" + s._utm_content;
    if (s.campaign === "||||" || s.campaign === "null|null|null|null|null") { s.campaign = "" }
}

or better yet:

if (!s.campaign) {
    s.campaign = [
      s.getQueryParam('utm_source'),
      s.getQueryParam('utm_medium'),
      s.getQueryParam('utm_campaign'),
      s.getQueryParam('utm_term'),
      s.getQueryParam('utm_content'),
    ].map((u) => {
      return (!u || u === 'null') ? '' : u;
    }).join('|');
    if (s.campaign === "||||") {
      s.campaign = "";
    }
}

View solution in original post

9 Replies

Avatar

Community Advisor and Adobe Champion

I'm not entirely sure why all your variables are being declared within the s object.... s.campaign is an actual tracking parameter and falls within the s object scope...

 

Things like s._utm_campaign do not... 

 

Same with adding the s object to the getQueryParam function... you shouldn't need the s object to be applied here.

 

I suspect the issue may come from a combination of these two unnecessary declaration into an invalid scope... there is no s._utm_campaign variable, there is no s.getQueryParam function, and by attempting to populate this way is causing confusion in the concatenation.

 

Try instead:

if (!s.campaign) {
    var _utm_campaign = getQueryParam('utm_campaign');
    var _utm_source = getQueryParam('utm_source');
    var _utm_medium = getQueryParam('utm_medium');
    var _utm_term = getQueryParam('utm_term');
    var _utm_content = getQueryParam('utm_content');
    s.campaign = _utm_source + "|" + _utm_medium + "|" + _utm_campaign + "|" + _utm_term + "|" + _utm_content;
    if (s.campaign === "||||") { s.campaign = "" }
}

 

Avatar

Level 4

Thank you very much. I was not using getQueryParam and that worked fine.

Avatar

Correct answer by
Community Advisor

Try this:

if (!s.campaign) {
    s._utm_campaign = s.getQueryParam('utm_campaign');
    s._utm_source = s.getQueryParam('utm_source');
    s._utm_medium = s.getQueryParam('utm_medium');
    s._utm_term = s.getQueryParam('utm_term');
    s._utm_content = s.getQueryParam('utm_content');
    s.campaign = s._utm_source + "|" + s._utm_medium + "|" + s._utm_campaign + "|" + s._utm_term + "|" + s._utm_content;
    if (s.campaign === "||||" || s.campaign === "null|null|null|null|null") { s.campaign = "" }
}

or better yet:

if (!s.campaign) {
    s.campaign = [
      s.getQueryParam('utm_source'),
      s.getQueryParam('utm_medium'),
      s.getQueryParam('utm_campaign'),
      s.getQueryParam('utm_term'),
      s.getQueryParam('utm_content'),
    ].map((u) => {
      return (!u || u === 'null') ? '' : u;
    }).join('|');
    if (s.campaign === "||||") {
      s.campaign = "";
    }
}

Avatar

Level 4

Thank you for the concise version. Appreciate it. Very helpful.

 

Below solved the issue for me

f (s.campaign === "||||" || s.campaign === "null|null|null|null|null") { s.campaign = "" }
}

Avatar

Community Advisor and Adobe Champion

Unfortunately, this won't prevent s.campaign from resulting in "value 1|value 2|null|null|null" etc, IF not all UTMs are provided in the URL.

 

If you want non-values to be treated as nothing and not null, (i.e. "value 1|value 2|||") this solution won't work.. it really only covers the "all or nothing" scenario

Avatar

Level 4

Thank you very much!! Will try that out

Avatar

Level 4

After doing that change, I went ahead and classified the s.campaign variable to point to those values. See Screenshot 1. But, below variables are not showing any data in Analysis Workspace . It shows unspecified. See Screenshot 3.

The tracking code report is showing the data in Analysis Workspace. See Screenshot 2

 

 

SCREENSHOT 1

ankitnagarsheth1_0-1657309133689.png

 

 

SCREENSHOT 2

ankitnagarsheth1_1-1657309258299.png

 

ankitnagarsheth1_2-1657309415067.png

 

Avatar

Community Advisor and Adobe Champion

Classification rules only process every 4-6 hours... and if you just created the classifications it can take up to 24 hours for the classifications to process the lookback window.

Avatar

Community Advisor

Also, you mentioned that you had configured the Classifications, but you didn't mention if you had actually imported any classifications data or are using Classification Rule Builder. If you have not done any of the latter, then obviously there won't be any classifications for AA to map to.