On our website we have a data layer to define some variables to be passed on to Google Analytics. It is defined like this:
deviceCategory: "DESKTOP"
deviceMode: "DESKTOP"
domainName: ".mydomain.com"
environment: "production"
operatingSystem: "UNKNOWN"
page.category.pageType: "Content"
page.category.primaryCategory: "main"
page.pageInfo.language: "en"
page.pageInfo.pageID: "productSelection"
user.profile.address.city: "Los Angeles"
user.profile.address.country: "US"
When I type the following in console it outputs exactly as expected: dataLayer[0].deviceMode --> "DESKTOP"
However, when I try to access any of the page/user variables I get errors: dataLayer[0].page.category.pageType --> Uncaught TypeError: Cannot read property 'category' of undefined
Any idea why this is happening? What is the proper way to access these values?