How to best Include User Agent string in the Datalayer

rune_a
Silver Contributor
Silver Contributor rune_a

Hi

I want to include the full User Agent string in my datalayer. 

I can read it can be seen by using "navigator.userAgent" but what is the best way to include this in the datalayer. I had actuel expected it would be a part of the tealium data set automatic tracked on the page (as DOM, Meta data etc is) 

Why now:

We have been using Webtrends and here it was automatic send by the tag. But it does not seems this is the case for Adobe Analytics. So now we would like to send it in a eVar.

6 REPLIES 6
Highlighted

How to best Include User Agent string in the Datalayer

Tealium Expert
Tealium Expert

I've not seen a better approach than using a Set Data Values extension to grab the following useful properties from the navigator API:

  • doNotTrack
  • language
  • userAgent
  • maxTouchPoints

If you want to be lazy and do it in pure JS, something like this would work:

["doNotTrack","language","userAgent","maxTouchPoints"].map((v) => b["nav." + v.toLowerCase()] = String(window.navigator[v]));

(might want to run it through Babel to de-ES6 it)

It populates the following UDO elements:

  • nav.donottrack
  • nav.language
  • nav.useragent
  • nav.maxtouchpoints

From their respective navigator properties.

How to best Include User Agent string in the Datalayer

rune_a
Silver Contributor
Silver Contributor rune_a

Thanks for a really quick answer.

Can you show a example on what you set in the  "Set Data Values" extension for the non-lazy solution.

Is it just simple  JS Code ?

How to best Include User Agent string in the Datalayer

Tealium Expert
Tealium Expert

Yeah, you just create a Set Data Values extension and map your UDO variable to the JS Code expression "navigator.userAgent" and it ought to work right out of the box.

How to best Include User Agent string in the Datalayer

tamedbeast
Silver Contributor
Silver Contributor tamedbeast

OOOooooooo @rune_a. I'd mark that as an accepted solution. #hinthint #winkwink

#hugs

If you liked it then you should have put a kudo on it!

How to best Include User Agent string in the Datalayer

Tealium Expert
Tealium Expert

I'm late to this party, @rune_a, but what's the real thing you want to solve?  Reporting the user agent value in Adobe Analytics or getting the UA into the data layer (UDO) for other reasons?

 

If you just want to get the UA into an Adobe Analytics eVar, I would recommend using Processing Rules to do it from within Adobe Analytics Report Suite configuration. The only possible snag there is if no one on the team is Processing Rules certified.  But that's easy enough to do in a short time, and it's beneficial to get that certification anyway as it opens many doors.

 

Looking forward to continuing this discussion.... cheers!

How to best Include User Agent string in the Datalayer

rune_a
Silver Contributor
Silver Contributor rune_a

Thanks @mitchellt - i had not even considered this was a option in Processing Rules. But i see it, and have tried to add it.

Sometime the obvious solution is to easy to be considered.  

In general i like to have the User Agent available in a analytics dataset for debugging.