Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

utm tracking through Adobe Launch custom code

Avatar

Level 4

I am trying to implement UTM tracking through the Adobe Launch custom code section in the extensions configure tracker custom code. I was curious to know what other ways I can capture the utm_campaign,utm_source, and utm_medium through Adobe Launch

 

Below is my code

 

  /* set s.campaign */
    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_campaign + "|" + s._utm_source + "|" + s._utm_medium + "|" + s._utm_term + "|" + s._utm_content;
        if(s.campaign === "||||"){s.campaign = ""};
    };  
  
   if(!s.campaign){
    s.cpcsource=s.getQueryParam('cpcsource');
    s.cpcmedium=s.getQueryParam('cpcmedium');
    s.cpccampaign=s.getQueryParam('cpccampaign');
    s.glcid=s.getQueryParam('glcid');
    s.campaign=s.cpcsource + "|" + s.cpcmedium + "|" + s.cpccampaign + "|" + s.glcid;
      if(s.campaign === "|||"){s.campaign = ""};
    };

d

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Yes, your code will work, although it is unnecessary to add all of those variables to the "s" global project. You can use standalone variables.
E.g.

  /* set s.campaign */
    if(!s.campaign){
        let _utm_campaign=s.getQueryParam('utm_campaign');
        let _utm_source=s.getQueryParam('utm_source');
        let _utm_medium=s.getQueryParam('utm_medium');
        let _utm_term=s.getQueryParam('utm_term');
        let _utm_content=s.getQueryParam('utm_content');
        s.campaign=_utm_campaign + "|" + _utm_source + "|" + _utm_medium + "|" + _utm_term + "|" + _utm_content;
        if(s.campaign === "||||"){s.campaign = ""};
    };  
  
   if(!s.campaign){
    let cpcsource=s.getQueryParam('cpcsource');
    let cpcmedium=s.getQueryParam('cpcmedium');
    let cpccampaign=s.getQueryParam('cpccampaign');
    let glcid=s.getQueryParam('glcid');
    s.campaign=cpcsource + "|" + cpcmedium + "|" + cpccampaign + "|" + glcid;
      if(s.campaign === "|||"){s.campaign = ""};
    };

There are other ways to optimise your code, especially since you're using Adobe Launch. But the above should suffice.

View solution in original post

0 Replies

Avatar

Correct answer by
Community Advisor

Yes, your code will work, although it is unnecessary to add all of those variables to the "s" global project. You can use standalone variables.
E.g.

  /* set s.campaign */
    if(!s.campaign){
        let _utm_campaign=s.getQueryParam('utm_campaign');
        let _utm_source=s.getQueryParam('utm_source');
        let _utm_medium=s.getQueryParam('utm_medium');
        let _utm_term=s.getQueryParam('utm_term');
        let _utm_content=s.getQueryParam('utm_content');
        s.campaign=_utm_campaign + "|" + _utm_source + "|" + _utm_medium + "|" + _utm_term + "|" + _utm_content;
        if(s.campaign === "||||"){s.campaign = ""};
    };  
  
   if(!s.campaign){
    let cpcsource=s.getQueryParam('cpcsource');
    let cpcmedium=s.getQueryParam('cpcmedium');
    let cpccampaign=s.getQueryParam('cpccampaign');
    let glcid=s.getQueryParam('glcid');
    s.campaign=cpcsource + "|" + cpcmedium + "|" + cpccampaign + "|" + glcid;
      if(s.campaign === "|||"){s.campaign = ""};
    };

There are other ways to optimise your code, especially since you're using Adobe Launch. But the above should suffice.

Avatar

Community Advisor

Don't use the getQueryParam plugin, Adobe Launch provides you the capability to get query params using default Core extension "Query String Parameter" data element.

 

Create one data element for each and then use _satellite.getVar('dataElementID')

Avatar

Level 4

Thank you so much!! This is super helpful to use 

 "Query String Parameter" data element. And, creating data element for each.