Expand my Community achievements bar.

SOLVED

Best practice for setting pageName to document.title

Avatar

Level 2

I am using DTM (and relatively new to it) and I have tried a number of approaches to automatically set the pageName variable to the document.title. I am trying to do as little custom code / js as possible and leverage the built in fields and features as much as possible. the closest I got was creating a data element. I was able to set an eVar to the data element just fine using the DTM fields and setting it to %variable%.  But when I try to set the PageName field to the same thing, instead of passing the value of the variable, it gets set to the literal string "window.document.title".

when I tried to use the custom jscript field, and tried s.pageName = _satellite.getVar('varName'); I get a console error that object s is undefined.

What is the "best practice" for doing this with DTM?

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi Mike,

Under the PageName field just put up '%window.document.title%' , that would automatically update the pagename variable with the page title. 

Let me know if that works for you.

Thanks!

View solution in original post

2 Replies

Avatar

Correct answer by
Employee

Hi Mike,

Under the PageName field just put up '%window.document.title%' , that would automatically update the pagename variable with the page title. 

Let me know if that works for you.

Thanks!

Avatar

Level 2

It does. that was one of the things I *thought* I tried, but I'm guessing it was user error on my part. e.g. leaving out the "window." :-\

 

thanks!