Our landing page URLs contain numerous parameters. I would like to populate a variable with a subset of these.
For example:Original: www.example.com/home.html?st=nc&leadsource=events&product=generic&vendor=abc&vanity_url=example.com-...Desired: www.example.com/home.html?leadsource=events&product=generic&vanity_url=example.com-ncevents
In this example, I have removed "st=nc" and "vendor=abc" as well as the "&"s.
Our real URLs can contain as much as 15 parameters and they're not always in the same order. I would also need to remove the associated "&" without removing the "?" if it's the first parameter.
After posting this I tried something that works but not well enough:
var OrigURL = "www.example.com/home.html?st=nc&leadsource=events&product=generic" var LSPos = OrigURL.indexOf('leadsource'); var LSPosEnd = OrigURL.indexOf('&',LSPos+1); var LSValue = OrigURL.substring(LSPos,LSPosEnd+1); var NewURL = OrigURL.replace(LSValue,""); _satellite.notify("OrigURL: "+OrigURL); _satellite.notify("LSPos: "+LSPos); _satellite.notify("LSPosEnd: "+LSPosEnd); _satellite.notify("LSValue: "+LSValue); _satellite.notify("NewURL: "+NewURL);
This works in removing the leadsource parameter but it has several problems
(1) If .indexof() returns -1 it will continue anyways
(2) It relies on the next "&" which may not exist if it's the last parameter
(3) I need a way to nest multiple of these and have the process continue to other parameters even if one of them is not found.
Ali Maleki wrote... Thanks for the reply Amit. Where would I use this? In a page load rule? Adobe Analytics Custom Page Code or 3rd party code? Can you walk me through the main areas of this? Ali
Ali Maleki wrote...
Thanks for the reply Amit.
Where would I use this? In a page load rule? Adobe Analytics Custom Page Code or 3rd party code?
Can you walk me through the main areas of this?
Adobe Analytics Custom Page Code
Question is that you want to remove certain variables from query string.. use the following sample code and see if this solves your problem.
I have not tested this so please fix the compiling errors if any.