Hi,
We've recently migrated to AppMeasurement library but it seems that s.Util.getQueryParam we've implemented consequently doesn't work properly.
1. Since s.Util.getQueryParam went live page url that is sent to Analytics contains clasifications IDs. Thus is case campaign landing page is www.oursite.com/landingpage/?clasificationID=1234 the page url that is sent to Analytics is www.oursite.com/landingpage/?clasificationID=1234 (should be www.oursite.com/landingpage/ only)
2. s.Util.getQueryParam should be able to parse out clasificationID in case the are other parameters in ulr (like anchors). Lets say landing page is: www.oursite.com/landingpage/?clasificationID=1234#section1 .In this case, clasificationID sent to analytics should only be clasificationID=1234, but in reports we see clasificationID=1234#section1.
Any explanation or fix tips would be appreciated.
Thanks!
Solved! Go to Solution.
Hi Vasek,
So for your #2 issue, it is a known issue and it has been reported to our engineering team.
For H version of Adobe Analytics code the getQueryParam plugin code contained the following line of code:
if(t){t=t.indexOf('#')>-" +"1?t.substring(0,t.indexOf('#')):t;}
This allowed the fragment part of a URI to not be returned.
With the new plugin s.Util.getQueryParam in AppMeasurement.js this functionality has been removed.
However with the new plugin you can specify you delimiter :
s.Util.getQueryParam(key, [url], [delim])
So you could if you desire specify any delimiter that you wish. This does not fix our issue unfortunately.
The solution would be to use a code that would filter out the value that you do not need. You can use the solution provided by Kaushalendra or you use code similar to the following:
function test(){ //List of delimiters to not include var list=["%","#"]; //extract the parameter that you need var value=s.Util.getQueryParam("key",'',"&"); //Remove the unnecessary values in the output var x; for (x in list) { if(value.indexOf(list[x])>-1){ value = value.substring(0,value.indexOf(list[x])); } } return value; }
URL exemple: www.mywebsite.com?cid=abc&key=1test%#param=123&test=vbn
The function above should return to you 123.
For your #1 it might not be linked to the plugin itself. So if you are talking about one of the link report then it might be due to s.linkLeaveQueryString : https://marketing.adobe.com/resources/help/en_US/sc/implement/linkLeaveQueryString.html
If it is in the Page report then it might be due to some backend settings, so please provide us the report suite and we can check.
Best regards.
Alexis Cazes
Senior Technical Support Engineer
Views
Replies
Total Likes
Hi Vasek,
So for your #2 issue, it is a known issue and it has been reported to our engineering team.
For H version of Adobe Analytics code the getQueryParam plugin code contained the following line of code:
if(t){t=t.indexOf('#')>-" +"1?t.substring(0,t.indexOf('#')):t;}
This allowed the fragment part of a URI to not be returned.
With the new plugin s.Util.getQueryParam in AppMeasurement.js this functionality has been removed.
However with the new plugin you can specify you delimiter :
s.Util.getQueryParam(key, [url], [delim])
So you could if you desire specify any delimiter that you wish. This does not fix our issue unfortunately.
The solution would be to use a code that would filter out the value that you do not need. You can use the solution provided by Kaushalendra or you use code similar to the following:
function test(){ //List of delimiters to not include var list=["%","#"]; //extract the parameter that you need var value=s.Util.getQueryParam("key",'',"&"); //Remove the unnecessary values in the output var x; for (x in list) { if(value.indexOf(list[x])>-1){ value = value.substring(0,value.indexOf(list[x])); } } return value; }
URL exemple: www.mywebsite.com?cid=abc&key=1test%#param=123&test=vbn
The function above should return to you 123.
For your #1 it might not be linked to the plugin itself. So if you are talking about one of the link report then it might be due to s.linkLeaveQueryString : https://marketing.adobe.com/resources/help/en_US/sc/implement/linkLeaveQueryString.html
If it is in the Page report then it might be due to some backend settings, so please provide us the report suite and we can check.
Best regards.
Alexis Cazes
Senior Technical Support Engineer
Views
Replies
Total Likes
It is a bug in the adobe script. between versions you took this out:
if(t){t=t.indexOf('#')>-"
08.+"1?t.substring(0,t.indexOf('#')):t;}
so you are not pulling off the hash anchor tag.
this is an undocumented change in behavior and should get fixed asap.
Hi
Use regex to split string after " # " , that would help.
Regards
Devinder
Views
Replies
Total Likes
@warrensander I would not say it is a bug as Client might want to put '#' intentionally in their URL parameters. In case they don't, they can use similar script as below to truncate the trailing part:
if(myParam){
myParam=myParam.indexOf('#')>0?myParam.substring(0,myParam.indexOf('#')):myParam;
}
Views
Replies
Total Likes
I wrote a custom getQueryParam plugin : https://github.com/alcazes/Adobe-Analytics-from-A-To-Z/wiki/Custom-s.Util.getQueryParam:-take-into-a...
It fixes:
Views
Replies
Total Likes
Hello Alexis.
It is really nice to emeet you. I am looking at this thread because it seems to be fixing a very fundamental issue for us, this is a company that does not use queryParams but only uses fragments throughout our urls. Thing is... we have tried your hotfix but it seems only to work with fragments when the test url includes a query param, and does not return anything when the url only includes the hash (#), no (?) anywhere. Now then, is it even posible to work only whith fragmnets? if so, how would we go about using only fragments... no (?) anchor anywhere in the url!
I am kind of desperate to get this to work, so anything towards that will be greatly apreciated!
Best regards
Views
Replies
Total Likes
my updated code does indeed have a bug somewhere. I think it would be easier to write your own plugin. You do not have to use Adobe Analytics one.
You can get all hash parameters using document.location.hash
Now if you have something like www.mywebsite.com#fragment1=value&fragment2=value2
Then you can use this code:
function getHashValue(key) {
var matches = location.hash.match(new RegExp(key+'=([^&]*)'));
return matches ? matches[1] : null;
}
Usage would be getHashValue('fragment1');
Views
Replies
Total Likes
Hi Alexis.
Thank you ever so much for your prompt response. I think you're are absolutely right with that, we are better off creating and managing our own plugins.
Thanks again for your response!
Best regards
Views
Replies
Total Likes
Hello Alexis.
I hope this message finds you well. We went ahead to create our own plugin which I placed under the plugin seccion of appMeasurement and commented the official getQueryParams 2.3. in order to avoid any possible conflict.
First of we call it vocQueryParams but eventhough it was working fine on the browser console, it did not work when tried to use it through processing rules. Next I changed the name of the plugin to be the same one as the official plugin (as you can see in the screenshot) hoping that will make the getQueryParams (ours) available from the processing rule interface. But that didn't work either.
What are we missing? Because from the plugin point of view, it works just fine. This is doing my head in
I already asked clientCare to no avail so I though perhaps you could shed some light into this matter.
Thanks ever so much for all your help!!
Views
Replies
Total Likes
Hi
I do not know what you mean by processing rules interface. The only processing rules that I know are the one you can set in Adobe Analytics Admin interface to add an additional level of processing once the data has been sent.
Using this processing rules does not require any addiitonal javascript code.
In your case if you can use the plugin in the console but it is not being used when you use it in the code to set up an eVar for Adobe Analytics then I would think that there is a race condition where your plugin is loaded to late. Or another thing, are you sure your analytics object is "s" ? It might have a different name when you initialize it.
The thing is that you do not have to set your "plugin" to be part of the Adobe Analytics object. This seems to be a misconception where people think that the plugin needs to be part of the Adobe Analytics object. It can be in a different object or its own standalone function loaded in a different file. I would actually advise you to decouple your function from Adobe Analytics object as it will allow you to reuse it for other purposes.
Thanks
Alexis
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies