Reputation: 13
I have a Data Layer event push in JS and was wondering if it is also possible to learn the User-Agent of the users triggering the event.
Upvotes: 1
Views: 7380
Reputation: 11
Google analytics custom dimension field can be maximum 150 characters and user agent data (when encoded) usually exceed the limit. You need to find a way to shorten the user agent information within a custom js script before sending to GA. You may crop the first 150 character of the user agent information or remove the unnecessary sections or remove the blank characters.
Upvotes: 1
Reputation: 1131
Even more simply, can't you use a "JavaScript Variable" (instead of a "Custom JavaScript" and then just set navigator.userAgent
?
Upvotes: 5
Reputation: 8736
You need to create variable which will return user agent
1) Go to Variables -> New
2) Name: User Agent
3) Type: Custom JavaScript
4) Code:
function () {return navigator.userAgent;}
Then you can use this variable in your tags like that {{User Agent}}
Upvotes: 6