utm tracking through Adobe Launch custom code | Community
Skip to main content
New Participant
May 25, 2022
Solved

utm tracking through Adobe Launch custom code

  • May 25, 2022
  • 2 replies
  • 2363 views

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

 

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

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.

2 replies

Alexis_Cazes_
New Participant
May 26, 2022

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')

xcode2295Author
New Participant
May 27, 2022

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

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

 

JyotiSharmaV
New Participant
August 10, 2022

@xcode2295 how did you map the data element? 

yuhuisg
yuhuisgAccepted solution
New Participant
May 26, 2022

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.

xcode2295Author
New Participant
May 27, 2022

Thank you. That's very helpful to use without s object.