Using UTM parameters in Adobe Analytics | Community
Skip to main content
carlos_santos
New Participant
August 7, 2017
Solved

Using UTM parameters in Adobe Analytics

  • August 7, 2017
  • 3 replies
  • 12710 views

Hi,

Im trying to extract the UTM parameters from the URL's to the campaign variable. I was using this method

http://analyticsdemystified.com/adobe-analytics/using-utm-campaign-parameters-adobe-analytics/

Unfortunately, from my understanding, I can't use the getQueryParam because im using the javascript of Appmeasurement. One solution is using the Util.getQueryParam, but unlike the plug-in, it doesn't support extracting multiple parameters at once.

Here's an example of what im trying to get:

From this URL:

www.exampledomain.com/?utm_source=emailing&utm_medium=email&utm_content=premium&utm_campaign=test-campaign

I want to extract something like this to the campaign variable:

emailing:email:premium:test-campaign

For that I used this sintax:

s.campaign = s.Util.getQueryParam("utm_campaign");

s.campaign = s.Util.getQueryParam("utm_source");

s.campaign = s.Util.getQueryParam("utm_medium");

s.campaign = s.Util.getQueryParam("utm_content");

But the final result is:

campaign = premium

This happens because each line is overwriting one another, correct? How can I extract all the parameters to the campaigns variable?

Thanks.

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 Urs_Boller

it happens, because you overwrite your var "campaign" every time you read a param.

use something like this in a data element:

var TCode[];

TCode.push(s.Util.GetQueryParam('utm_campaign'));

// repeat line above for each param

var TCfinal;

TCfinal = TCode.join(':');

return (TCfinal == '::::') ? '' : TCfinal;

// maybe you need to change condition if you have less than 5 params

afterwards you can use your DataElement in your Rules with %elementName%

3 replies

New Participant
January 8, 2019

Use the concatenation method here for an easier solution How to Capture multiple query parameters in the s.util.getQueryparam

New Participant
February 1, 2018

Hi,

the custom code mentioned here shows an error for line 1. the "[ ]" are not accepted. only way to save the code was to declare TCode as a variable not an array. could you help with the syntax to declare an array for custom data element?

Thanks!

Urs_Boller
Urs_BollerAccepted solution
New Participant
August 7, 2017

it happens, because you overwrite your var "campaign" every time you read a param.

use something like this in a data element:

var TCode[];

TCode.push(s.Util.GetQueryParam('utm_campaign'));

// repeat line above for each param

var TCfinal;

TCfinal = TCode.join(':');

return (TCfinal == '::::') ? '' : TCfinal;

// maybe you need to change condition if you have less than 5 params

afterwards you can use your DataElement in your Rules with %elementName%