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
Solved! Go to Solution.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
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.
Views
Replies
Total Likes
Thank you. That's very helpful to use without s object.
Views
Replies
Total Likes
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')
Views
Replies
Total Likes
Thank you so much!! This is super helpful to use
"Query String Parameter" data element. And, creating data element for each.
Views
Replies
Total Likes
@xcode2295 how did you map the data element?
Views
Replies
Total Likes
Views
Like
Replies
Views
Like
Replies