How to access AudienceStream visitor attributes in JavaScript Extension?

Bronze Contributor
Bronze Contributor
We'd like to access visitor attribute value such as badges, metrics, etc from AudienceStream within a tiq JavaScript extension. In the current setup, we have AudienceStream enabled and DataCloud tag pulling frequently. We actually CAN successfully access all "va" variables IF we enable the "modal" extension and it fires. At that point all va variables become part of utag.data. However, we'd like to access without the modal extension firing. So, since the va data is available somewhere, the question is how can we tell tealium iq to merge the va attributes into utag.data or how access it otherwise?
5 REPLIES 5

How to access AudienceStream visitor attributes in JavaScript Extension?

Employee Emeritus

Hi Matt,

 

If have data layer enrichment in the Data Cloud tag set to 'frequent' then utag.data will be enriched every page view (if it is set to 'infrequent' then it will be updated once per visit with the latest version).

 

See documentation : https://community.tealiumiq.com/t5/AudienceStream/Data-Layer-Enrichment/ta-p/684

 

Either way, all of your visitors should have all of the relevant AS attributes available in the data layer and you can check them by entering 'utag.data' into the console:

 

http://note.io/1BlLNlK

 

If you want to refer to them you can refer to them as:

 

utag.data['data source name'] (e.g. utag.data['va.properties.5249'])

 

In the above example, '5249' is the unique data source ID which can be found here:

 

http://note.io/1BlM0p8

 

Depending on the attribute type you will need to change 'properties' to 'badges' or 'metrics' etc but you can see this in the console.

 

I hope this helps!

 

Thanks, Roshan

How to access AudienceStream visitor attributes in JavaScript Extension?

Bronze Contributor
Bronze Contributor
Roshan, Thank you very much for you response. As I mentioned we actually can sometimes see and access the va attributes inside the utag.data. So we did some more research. Here is what seems to happen: Initially, when loading the first page in a visit, the utag.data does not contain the visitor attributes. After refreshing that same page three times, the utag.data suddenly shows the va attributes. Of course we'd like to do this without reloading the page three times. Any ideas or suggestions? Matt

How to access AudienceStream visitor attributes in JavaScript Extension?

Tealium Employee

Hi Matt,

What you are seeing is the expected behavior for a 1st-time visitor of the website. Here are the actual steps from the 1st visit from an AudienceStream (AS) perspective:

Page View 1:
- Send data to AS
- Since no visitor profile data exists for the customer, we do not request the visitor's profile on page one

Page View 2:
- Send data to AS
- Request updated visitor profile from AS and place into Local Storage

Page View 3:
- Send data to AS
- Read Local Storage from previous page view and inject data into UDO
- Request updated visitor profile from AS and place into Local Storage

Page View 4+:
- Mimic's Page View 3

Due to the asynchronous nature of the Tealium iQ solution, we do not stop the page from loading to get the updated visitor profile; this is why we read Local Storage before requesting the updated visitor profile.

Also, this means that data enrichment is always at least 2 page views behind (e.g. page view 3 reads Local Storage from page view 2 which contains data from page view 1), possibly 3 page views depending on how fast the visitor navigates between pages.

Upon the visitors next session, as long as the visitor does not clear cache and cookies between visits then Local Storage will persist between sessions meaning the data is available on initial page view. This should help resolve the issue of the data not being available on the 1st page view.

Please reply with any questions.

How to access AudienceStream visitor attributes in JavaScript Extension?

Bronze Contributor
Bronze Contributor
Thanks Dan, that explains it. We'll have to find a way on our side how we'll deal with AS lagging two page views behind. Not sure how yet though since the intention was to use this for real-time automation and optimization. Best - Matt

How to access AudienceStream visitor attributes in JavaScript Extension?

Tealium Employee

Hi Matt,

Understood. I hinted to this in my previous comment, but trying to get AS data sent, processed, and back to the webpage for immediate use would require synchronous logic and negatively effect page performance. With a best practice of Tealium iQ being to wait until DOM Ready to trigger tags, the page will already be displayed to the visitor before the data is event sent to AS. Even if we were able to get the enriched data back into the UDO on the same page, visitors would experience flicker as content is changed post DOM Ready.

Your best option is to talk to your Deployment team because without use cases and vendor knowledge I can only provide general guidelines. But my intention is to at least get you started in the right direction.

While Data Enrichment is one way to enrich vendor data, AudienceStream has several connectors that can be used to send data to vendors. If you don't see the vendor you need (like Adobe Target or your CMS), you can still leverage the Webhook and AudienceDirect connectors to POST or GET data to an endpoint. This way when the page loads and AS is sent the data, AS will immediately enrich the data and trigger off the API calls so that the vendors will have the data available on the next page load. This is the fastest the data will be available for automation and optimization. Otherwise you'll need to leverage the standard UDO via Tealium iQ to automate and optimize.

Let me know if there are any other questions!

Public