GetPageName Plugin using DTM | Community
Skip to main content
sanmeetw1519854
Level 3
October 16, 2015
Solved

GetPageName Plugin using DTM

  • October 16, 2015
  • 3 replies
  • 3129 views

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

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 whatever_you_want

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 replies

Rahsing
Level 9
October 16, 2015

Hi,

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

Thanks

Rahul

whatever_you_wantAccepted solution
Level 2
October 16, 2015

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!

July 15, 2016

Thanks! this helped me :)