For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Resources
Get started
ReferenceChangelog
ReferenceChangelog
  • Browser API
    • wf.ready()
  • Consent Management
    • Get consent status
    • Allow user tracking
    • Deny user tracking
  • Optimize
    • Quickstart
    • Variations
    • Custom attributes
      • Get attributes
      • Get all attributes
      • Set attributes
      • Delete attributes
      • Delete all attributes
  • Custom Goals
    • On-site conversions
    • Off-site conversions
  • Data Exports
    • Data destinations
    • Data schema
  • Additional Resources
    • Support Documentation
LogoLogo
Resources
Get started
On this page
  • wf.getAttributes(scope, names)
OptimizeCustom attributes

Get Attributes

Was this page helpful?
Previous

Get all attributes

Next
Built with

wf.getAttributes(scope, names)

Retrieve a subset of attributes that have been previously stored using setAttributes(). Only attributes that match the names parameter will be returned.

Syntax

1wf.getAttributes(scope: 'user' | 'pageview', names: string[])

Parameters

  • scope: 'user' | 'pageview' - The scope of the attributes to retrieve.
  • names: string[] - An array of attribute names to retrieve.

Example implementation

1// Call the wf.ready() function the Browser API is available
2wf.ready(function() {
3 // Set attributes for the current user
4 wf.setAttributes('user', {
5 userSegment: 'enterprise'
6 })
7})
8
9// Retrieve the attributes
10const attributes = wf.getAttributes('user', ['userSegment'])
11 console.log(attributes)

Returns

An object containing the attributes that match the names parameter.

Example

1{
2 "userSegment": "enterprise"
3}