When I add the following in script.js in a ZenDesk template, user properties are returned successfully:
var userRole = HelpCenter.user.role;
console.log(userRole)
This works also
var isAdmin = HelpCenter.user.is_admin;
console.log(isAdmin)
However, I can't get article properties to return. For example, drawing from this documentation, the following code returns TypeError: Cannot read properties of undefined (reading 'id')
:
var articleId = HelpCenter.article.id;
console.log(articleId)
And, following this documentation the following code returns TypeError: Cannot read properties of undefined (reading 'name')
:
var categoryName = HelpCenter.category.name;
console.log(categoryName)
I use the first two code snippets to send the user role and admin status to custom definitions in Google Analytics 4.
I would like to send the page category to Google Analytics 4 as well.
If there is a better way to send article properties like the page category to Google Analytics 4, I would be grateful to know.
Thank you for any time.