Tracking URL with dynamic value | Community
Skip to main content
August 5, 2022
Solved

Tracking URL with dynamic value

  • August 5, 2022
  • 1 reply
  • 2380 views

Hi,

 

Is it possible to capture custom value dynamically for an url that we provide?  Basically, we are looking to use tracking id and a custom value to identify an user behaviour.  For example, is it possible to do something like this in AA?  www.test.ca?cid=122&colour=red   colour=red needs to be dynamically populated.  Is that something that can be done?

 

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 Jennifer_Dungan

Technically yes, with the right code... 

 

First off, is both 'colour' and 'red' dynamic? Or just 'red'?

 

If just 'red' is dynamic, this is a lot easier... you can just create a data element using "Query String Parameter" and specifying "colour" as the item:

 

 

However, if 'colour' could also be dynamic, you will need to write custom code to extra and process this from your string... and you will need to determine rules on how you want to collect it.. what if there are more than one parameter provided (?cid=123&colour=red&shape=square), do you want them all concatenated into a comma separate list?

 

The following JS will get ALL querystrings:

var allparams = window.location.search;

allparams will get '?cid=234&colour=red&shape=square'

 

Then you can use JS to process this data how you need it to be processed, and pass that to the prop or evar of your choice.. or into your s.campaigns

 

Maybe you only want cid in s.campaigns, and colour and shape to be somewhere else.. you can use JS to parse out the cid and value, leaving you with extra params to use as you wish.

1 reply

Jennifer_Dungan
Community Advisor and Adobe Champion
Jennifer_DunganCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
August 6, 2022

Technically yes, with the right code... 

 

First off, is both 'colour' and 'red' dynamic? Or just 'red'?

 

If just 'red' is dynamic, this is a lot easier... you can just create a data element using "Query String Parameter" and specifying "colour" as the item:

 

 

However, if 'colour' could also be dynamic, you will need to write custom code to extra and process this from your string... and you will need to determine rules on how you want to collect it.. what if there are more than one parameter provided (?cid=123&colour=red&shape=square), do you want them all concatenated into a comma separate list?

 

The following JS will get ALL querystrings:

var allparams = window.location.search;

allparams will get '?cid=234&colour=red&shape=square'

 

Then you can use JS to process this data how you need it to be processed, and pass that to the prop or evar of your choice.. or into your s.campaigns

 

Maybe you only want cid in s.campaigns, and colour and shape to be somewhere else.. you can use JS to parse out the cid and value, leaving you with extra params to use as you wish.

SCB21Author
August 9, 2022

Hi @jennifer_dungan,

 

Thanks for this.  Are we able to pull that information from a partner site to our data layer.  Basically, we want to provide that url to our partner to implement, but they don't have AA.  Is this doable in that case?

 

Thanks

Jennifer_Dungan
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
August 9, 2022

Is the link going from you to your partner site... or coming to your site from a link on your partner site?

 

Basically you can only track what is happening on your own site... this is the purpose of campaign tracking... a partner, or a marketing campaign in Social Media for instance (where you cannot track) links to your site... they add some querystring parameters to the link that is opened on your site, so that you can read them, and track those PVs/Visits/Conversions/etc back to whatever campaign was running off your site.

 

Controversy, I supposed if you are linking out to partner, you could do some fancy code on the exit link to pick up the outgoing campaign (into a custom prop or evar... don't mess up your site's campaign tracking)...