s.campaign showing null values | Community
Skip to main content
New Participant
July 7, 2022
Solved

s.campaign showing null values

  • July 7, 2022
  • 3 replies
  • 2066 views

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 = "" } }

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by yuhuisg

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 = "";
    }
}

3 replies

xcode2295Author
New Participant
July 8, 2022

Thank you very much!! Will try that out 🙂

xcode2295Author
New Participant
July 8, 2022

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

 

 

SCREENSHOT 2

 

 

Jennifer_Dungan
New Participant
July 8, 2022

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.

yuhuisg
yuhuisgAccepted solution
New Participant
July 8, 2022

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 = "";
    }
}
xcode2295Author
New Participant
July 8, 2022

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 = "" }
}
Jennifer_Dungan
New Participant
July 8, 2022

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

Jennifer_Dungan
New Participant
July 7, 2022

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 = "" }
}

 

xcode2295Author
New Participant
July 8, 2022

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