내 커뮤니티 업적 표시줄을 확대합니다.

Adobe Experience Platform (AEP) & Apps User Groups are live to Network, learn, and share in your regional locations.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

GetPageName Plugin using DTM

Avatar

Level 4

hi,

I am trying to use the getPageName plugin. But I am getting the following error -

cannot read property 'location' of undefined. Can someone help me with this?

Regards,

Sanmeet

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Level 2

Hi Sanmeet,

I ran into the same issue but it wasn't related to DTM. It was related to upgrading from H.25 code to AppMeasurment.js. A function that getPageName() relies on was removed in AppMeasurement.js.  The code below should help you get the plugin working again if you still need it. the JavaScript below was provided to me by Adobe Support.

To use this, just paste it directly after " function s_doPlugins(s) {  "

    s.wd=window;
    s.fl=new Function("x","l",""
    +"return x?(''+x).substring(0,l):x");
    s.pt=new Function("x","d","f","a",""
    +"var s=this,t=x,z=0,y,r,l='length';while(t){y=t.indexOf(d);y=y<0?t[l"
    +"]:y;t=t.substring(0,y);r=s[f](t,a);if(r)return r;z+=y+d[l];t=x.subs"
    +"tring(z,x[l]);t=z<x[l]?t:''}return''");
    s.rep=new Function("x","o","n",""
    +"var a=new Array,i=0,j;if(x){if(x.split)a=x.split(o);else if(!o)for("
    +"i=0;i<x.length;i++)a[a.length]=x.substring(i,i+1);else while(i>=0){"
    +"j=x.indexOf(o,i);a[a.length]=x.substring(i,j<0?x.length:j);i=j;if(i"
    +">=0)i+=o.length}}x='';j=a.length;if(a&&j>0){x=a[0];if(j>1){if(a.joi"
    +"n)x=a.join(n);else for(i=1;i<j;i++)x+=n+a[i]}}return x");
    s.ape=new Function("x",""
    +"var s=this,h='0123456789ABCDEF',f='+~!*()\\'',i,c=s.charSet,n,l,e,y"
    +"='';c=c?c.toUpperCase():'';if(x){x=''+x;if(s.em==3){x=encodeURIComp"
    +"onent(x);for(i=0;i<f.length;i++){n=f.substring(i,i+1);if(x.indexOf("
    +"n)>=0)x=s.rep(x,n,'%'+n.charCodeAt(0).toString(16).toUpperCase())}}"
    +"else if(c=='AUTO'&&('').charCodeAt){for(i=0;i<x.length;i++){c=x.sub"
    +"string(i,i+1);n=x.charCodeAt(i);if(n>127){l=0;e='';while(n||l<4){e="
    +"h.substring(n%16,n%16+1)+e;n=(n-n%16)/16;l++}y+='%u'+e}else if(c=='"
    +"+')y+='%2B';else y+=escape(c)}x=y}else x=s.rep(escape(''+x),'+','%2"
    +"B');if(c&&c!='AUTO'&&s.em==1&&x.indexOf('%u')<0&&x.indexOf('%U')<0)"
    +"{i=x.indexOf('%');while(i>=0){i++;if(h.substring(8).indexOf(x.subst"
    +"ring(i,i+1).toUpperCase())>=0)return x.substring(0,i)+'u00'+x.subst"
    +"ring(i);i=x.indexOf('%',i)}}}return x");
    s.epa=new Function("x",""
    +"var s=this,y,tcf;if(x){x=s.rep(''+x,'+',' ');if(s.em==3){tcf=new Fu"
    +"nction('x','var y,e;try{y=decodeURIComponent(x)}catch(e){y=unescape"
    +"(x)}return y');return tcf(x)}else return unescape(x)}return y");
    s.parseUri=new Function("u",""
    +"if(u){u=u+'';u=u.indexOf(':')<0&&u.indexOf('//')!=0?(u.indexOf('/')"
    +"==0?'/':'//')+u:u}u=u?u+'':window.location.href;var e,a=document.cr"
    +"eateElement('a'),l=['href','protocol','host','hostname','port','pat"
    +"hname','search','hash'],p,r={href:u,toString:function(){return this"
    +".href}};a.setAttribute('href',u);for(e=1;e<l.length;e++){p=l[e];r[p"
    +"]=a[p]||''}delete a;p=r.pathname||'';if(p.indexOf('/')!=0)r.pathnam"
    +"e='/'+p;return r");
    s.gtfs=new Function(""
    +"var w=window,l=w.location,d=document,u;if(!l.origin)l.origin=l.prot"
    +"ocol+'//'+l.hostname+(l.port?':'+l.port:'');u=l!=w.parent.location?"
    +"d.referrer:d.location;return{location:s.parseUri(u)}");

Hope that helps!

원본 게시물의 솔루션 보기

3 답변 개

Avatar

Level 8

Hi,

Could you please elaborate on your setup and what it is you're trying to capture.

Thanks

Rahul

Avatar

정확한 답변 작성자:
Level 2

Hi Sanmeet,

I ran into the same issue but it wasn't related to DTM. It was related to upgrading from H.25 code to AppMeasurment.js. A function that getPageName() relies on was removed in AppMeasurement.js.  The code below should help you get the plugin working again if you still need it. the JavaScript below was provided to me by Adobe Support.

To use this, just paste it directly after " function s_doPlugins(s) {  "

    s.wd=window;
    s.fl=new Function("x","l",""
    +"return x?(''+x).substring(0,l):x");
    s.pt=new Function("x","d","f","a",""
    +"var s=this,t=x,z=0,y,r,l='length';while(t){y=t.indexOf(d);y=y<0?t[l"
    +"]:y;t=t.substring(0,y);r=s[f](t,a);if(r)return r;z+=y+d[l];t=x.subs"
    +"tring(z,x[l]);t=z<x[l]?t:''}return''");
    s.rep=new Function("x","o","n",""
    +"var a=new Array,i=0,j;if(x){if(x.split)a=x.split(o);else if(!o)for("
    +"i=0;i<x.length;i++)a[a.length]=x.substring(i,i+1);else while(i>=0){"
    +"j=x.indexOf(o,i);a[a.length]=x.substring(i,j<0?x.length:j);i=j;if(i"
    +">=0)i+=o.length}}x='';j=a.length;if(a&&j>0){x=a[0];if(j>1){if(a.joi"
    +"n)x=a.join(n);else for(i=1;i<j;i++)x+=n+a[i]}}return x");
    s.ape=new Function("x",""
    +"var s=this,h='0123456789ABCDEF',f='+~!*()\\'',i,c=s.charSet,n,l,e,y"
    +"='';c=c?c.toUpperCase():'';if(x){x=''+x;if(s.em==3){x=encodeURIComp"
    +"onent(x);for(i=0;i<f.length;i++){n=f.substring(i,i+1);if(x.indexOf("
    +"n)>=0)x=s.rep(x,n,'%'+n.charCodeAt(0).toString(16).toUpperCase())}}"
    +"else if(c=='AUTO'&&('').charCodeAt){for(i=0;i<x.length;i++){c=x.sub"
    +"string(i,i+1);n=x.charCodeAt(i);if(n>127){l=0;e='';while(n||l<4){e="
    +"h.substring(n%16,n%16+1)+e;n=(n-n%16)/16;l++}y+='%u'+e}else if(c=='"
    +"+')y+='%2B';else y+=escape(c)}x=y}else x=s.rep(escape(''+x),'+','%2"
    +"B');if(c&&c!='AUTO'&&s.em==1&&x.indexOf('%u')<0&&x.indexOf('%U')<0)"
    +"{i=x.indexOf('%');while(i>=0){i++;if(h.substring(8).indexOf(x.subst"
    +"ring(i,i+1).toUpperCase())>=0)return x.substring(0,i)+'u00'+x.subst"
    +"ring(i);i=x.indexOf('%',i)}}}return x");
    s.epa=new Function("x",""
    +"var s=this,y,tcf;if(x){x=s.rep(''+x,'+',' ');if(s.em==3){tcf=new Fu"
    +"nction('x','var y,e;try{y=decodeURIComponent(x)}catch(e){y=unescape"
    +"(x)}return y');return tcf(x)}else return unescape(x)}return y");
    s.parseUri=new Function("u",""
    +"if(u){u=u+'';u=u.indexOf(':')<0&&u.indexOf('//')!=0?(u.indexOf('/')"
    +"==0?'/':'//')+u:u}u=u?u+'':window.location.href;var e,a=document.cr"
    +"eateElement('a'),l=['href','protocol','host','hostname','port','pat"
    +"hname','search','hash'],p,r={href:u,toString:function(){return this"
    +".href}};a.setAttribute('href',u);for(e=1;e<l.length;e++){p=l[e];r[p"
    +"]=a[p]||''}delete a;p=r.pathname||'';if(p.indexOf('/')!=0)r.pathnam"
    +"e='/'+p;return r");
    s.gtfs=new Function(""
    +"var w=window,l=w.location,d=document,u;if(!l.origin)l.origin=l.prot"
    +"ocol+'//'+l.hostname+(l.port?':'+l.port:'');u=l!=w.parent.location?"
    +"d.referrer:d.location;return{location:s.parseUri(u)}");

Hope that helps!

Avatar

Level 1

Thanks! this helped me 🙂