Adobe DTM to set query string in eVar and sProp

风流意气都作罢 提交于 2019-12-08 04:24:18

问题


So normally I would use the s.getQueryParam(); to parse out my URLs for query strings that I've been using.

s.eVar8=s.getQueryParam('cid,pid,eid',':');
s.prop28=s.getQueryParam('Role');

But since DTM has that all built into it, how would you really define that? I know I can set a page load rule using the campaign variable, but what if I have multiple parameters separated by ":"

www.domain.com?cid=blah1:blah2:blah3&pid=blah4:blah5:blah6&eid=blah7:blah8:blah9

Is there something that I'm missing when using this approach? Should I be capture these values into a data element then passing the data element into a page load rule using an eVar or sProp?


回答1:


For variables that only look for a single URL parameter:

Create a Data Element of Type URL Parameter. For Parameter Name, put e.g. "Role" (no quotes) for prop28. Alternatively, you can do the same thing below, for multiple.

For variables that look for multiple URL parameters:

Create a Data Element of Type Custom Script. Click the [Open Editor] button and in the code box, add the following:

var d=':',
    p=['cid','pid','eid'],
    v=[],c,l,q;
for (c=0,l=p.length;c<l;c++) {
  q=_satellite.getQueryParamCaseInsensitive(p[c]);
  if (q) v.push(q);
}
return v.join(d);

The d= and p= values are based on what you have for eVar8. This isn't 100% the same as AA's s.getQueryParam plugin but it's most of it; the parts you care about based on your posted code.

Reference the Data Element(s)

In the Adobe Analytics tool config, in the Global Variables section, you can add your prop(s) and eVar(s) there, using %data_element_name_here% syntax.



来源:https://stackoverflow.com/questions/41496244/adobe-dtm-to-set-query-string-in-evar-and-sprop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!