Javascript Tag technical guide

How does the Lexer Javascript Tag work?

The Lexer Javascript Tag works by first deploying a list of instructions using HTML and Javascript (of course!) in your chosen Tag Manager. These instructions will identify the variables and triggers on your website’s dataLayer that will populate our "out of the box" attributes to enrich your customer data.

For a quick refresher, see our Lexer Javascript Tag basics article.

Javascript Tag basics

For the initial setup of the tag, the following lines below (bespoke to your use case) will be provided to you by Lexer. You should place these lines as high in the head or body of your website as you can, or within an HTML tag in your tag manager.

This is the Lexer Tag - Header that will initialize attributes on your website, and where your customers' actions on site will be stored and then sent to the Lexer platform through a payload.

The other Lexer tags in this article are the instructional tags that will tell the tags when to fire (on what events/triggers) and what customer behavior (out of the box variables/attributes) to capture from your website's dataLayers.

lxt() function

The [.code]lxt()[.code] function is the backbone of the tag. We interact with it through all the major commands.

There are four primary methods we will use in every implementation:

  1. [.code]lxt('initiate', , )[.code]: is used to initiate the tag and provide the all important client identifier and attributes we’ll be tracking.
  2. [.code]lxt('identify', , )[.code]: is used to identify the user in the session.
  3. [.code]lxt('track', , )[.code]: is used to assign actions to the identified user.
  4. [.code]lxt('converted')[.code]: is used to call this at the end of a conversion funnel, and it will send all metadata associated with the session to Lexer.

1. lxt(‘initiate’, {id}, {attributes})

Lexer will provide you with the exact code to use here, with the id and list of attributes defined, as this list will be different for each client.

The code will look like this:

2. lxt(‘identify’, {key}, {value})

This call assigns an identity to the current user. As Lexer’s platform deals only with identified data, anonymous users will not be tracked through their browsing journey, so providing an identifier early in the user’s browsing journey is a priority.

However, our tracking code is aware that on many websites, identification might not happen until very late in the funnel, for example, at checkout. So the identify call can take place at any time in the funnel, and we ensure that any previous events within that session will be sent to the CDXP.

Here's an example of the full request:

[.code]lxt('identify', window.lxt_attributes.email, 'myemail@mysite.com')[.code]

The parameters are as follows:

  • key: Must be the name of one of the attributes in the provided [.code]lxt_attributes[.code] list.
  • In the above example, email would be the correct key.
  • value: Is a string or number identifier of the customer.
  • Once an identity has been assigned, a cookie is used to track subsequent visits — so long as the user’s browser supports them.

Lexer supports many different types of identifiers, besides email. Contact support@lexer.io for more details.

3. lxt(‘track’, {action}, {value})

This call assigns attributes to the identity in the CDXP. It takes two parameters:

  • key: Must be the name of one of the actions provided in [.code]lxt_attributes[.code].
  • value: Is a string, number, or boolean value to be assigned to the attribute.

If more complex data types are required, then consider these approaches:

  • arrays: Make multiple track requests for each value in the array.
  • objects/dictionaries: Should be configured as separate attributes, have a chat with Lexer Support (support@lexer.io) for an ideal strategy.
  • dates: Two options, convert this into a string (in an ISO8601 date format) or make them a UNIX date stamp (just be sure to convert the value to seconds).

Here is an example of the full request:

[.code]lxt('track', lxt_actions.added_product, 'metadata tshirt')[.code]

4. lxt(‘converted’)

Call this at the end of a conversion funnel, and it will send all metadata associated with the session to Lexer. This will allow for the populating of attributes such as device_id, device_used, and time_spent_to_convert.

Other lxt() Commands

lxt(‘debug’, true)

When implementing, you might want additional debug information to be generated from the tag. Simply call [.code]lxt('debug', true)[.code] to enable and look at the javascript console for details.

lxt(‘reset’)

Resets the user's cache and should be called at the point of a user logging out. This ensures the next person using the device will not get associated with the same cookie.

Further reading

That's it for our technical guide. For initial setup just follow the steps above and if you get confused or stuck please don't hesitate tor reach out for help at support@lexer.io. The following tag articles in this section expand on how the dataLayer can be configured with Shopify. See our further reading suggestions below.

Updated:
April 25, 2025
Did this page help you?
Thank you! Your feedback has been received!
Oops! Something went wrong while submitting the form, for assistance please contact support@lexer.io
Understanding APIs
Data
Developer APIs
Developer API overview
Data
Developer APIs
Javascript Tag basics
Data
Javascript Tag
Welcome to Lexer!
Fundamentals
Getting started
Identity Resolution
Fundamentals
Getting started
Our glossary
Fundamentals
Getting started
Integrations
Fundamentals
Setup
My account
Fundamentals
Setup
Manage team
Fundamentals
Setup
Group permissions
Fundamentals
Setup
Classifications
Fundamentals
Setup
Out of the box segments
Fundamentals
Setup
Lexi your AI companion
Fundamentals
Getting started
Browser guide
Fundamentals
Security
Corporate networks
Fundamentals
Security
Multi-factor authentication
Fundamentals
Security
Single sign-on
Fundamentals
Security
Lexer's ultimate troubleshooting guide
Fundamentals
Troubleshooting
Troubleshooting tech issues
Fundamentals
Troubleshooting
Troubleshooting integrations
Fundamentals
Troubleshooting
Troubleshooting Activate
Fundamentals
Troubleshooting
Troubleshooting Respond
Fundamentals
Troubleshooting
Help! My data is missing from the Hub
Fundamentals
Troubleshooting
How data is ingested into the CDP
Data
Self Serve Onboarding
Getting started onboarding data
Data
Self Serve Onboarding
Providing JSON data to Lexer
Data
Self Serve Onboarding
Providing CSV data to Lexer
Data
Self Serve Onboarding
Upload using SFTP
Data
Self Serve Onboarding
Secure file upload
Data
Self Serve Onboarding
Upload using S3
Data
Self Serve Onboarding
Lexer data specification
Data
Data Specification
Customer data specification
Data
Data Specification
Commerce data specification
Data
Data Specification
Marketing data specification
Data
Data Specification
Compliance data specification
Data
Data Specification
Data formatting and validation
Data
Data Specification
Rate limits
Data
Developer APIs
Product imagery
Data
Data Specification
Currency conversion
Data
Data Specification
Dataset management
Data
Data Management
Getting started with Logs
Data
Data Management
Chatbot API
Data
Developer APIs
Activity API
Data
Developer APIs
Read API
Data
Developer APIs
Javascript Tag use cases
Data
Javascript Tag
Export to CSV
Measure
Listen
Data in the CDXP
Data
Customer Data
CRM data
Data
Customer Data
Transaction data
Data
Customer Data
Email engagement data
Data
Customer Data
Experian data enrichment
Data
Customer Data
File upload API
Data
Developer APIs
Segment overview
Understand
Segment
Creating segments
Understand
Segment
Smart Search
Understand
Segment
Export attribute results
Understand
Segment
Fixing a disabled segment
Understand
Segment
Profile tab
Understand
Segment
Event Explorer
Understand
Segment
Lexer's attributes
Understand
Attributes
Predictive attributes
Understand
Attributes
Attribute value types
Understand
Attributes
Compare segments
Understand
Compare
Compare attributes
Understand
Compare
Activate overview
Engage
Activate
Ongoing activations
Engage
Activate
Audience splits
Engage
Activate
A/B splits
Engage
Activate
Control group splits
Engage
Activate
Inbox filtering
Engage
Respond
Ignored Senders
Engage
Respond
Forms for service
Engage
Respond
Workflow states
Engage
Respond
Bulk changes
Engage
Respond
Scheduled replies
Engage
Respond
Message templates
Engage
Respond
Customer profiles
Engage
Respond
Grouped messages
Engage
Respond
Automation rules
Engage
Respond
Redact messages
Engage
Respond
Contact Reporting
Engage
Contact
Serve Forms
Engage
Serve
Serve Reports
Engage
Serve
Serve Currency
Engage
Serve
Track overview
Measure
Track
Track Tables
Measure
Track
Activity overview
Measure
Activity
Team report
Measure
Activity
Cases report
Measure
Activity
Listen overview
Measure
Listen
Searching in Listen
Measure
Listen
Tier filters
Measure
Listen
Boolean search
Measure
Listen
Saved dives
Measure
Listen
Email notifications
Measure
Listen
Twitter data
Measure
Listen
Facebook data
Measure
Listen
Visualize overview
Measure
Visualize
Curate feed
Measure
Visualize
Report overview
Measure
Listen
Lexer Product Recommender → Klaviyo Integration
Grow
Lexer Product Recommender → Klaviyo Integration
Where do your best customers live? Use geographic insights to maximize media spend and conversion
Grow
Where do your best customers live? Use geographic insights to maximize media spend and conversion
Suppression audiences: How to use them and maximize your media effectiveness
Enrich
Suppression audiences: How to use them and maximize your media effectiveness
Measure campaign effectiveness: Track your KPIs and report on campaign performance
Enrich
Measure campaign effectiveness: Track your KPIs and report on campaign performance
Converting prospects: Acquire customers from your current, engaged prospect base (and save your ad spend!)
Acquire
Converting prospects: Acquire customers from your current, engaged prospect base (and save your ad spend!)
Understanding customer intent: Effective message personalization for buyers who shop outside their gender
Grow
Understanding customer intent: Effective message personalization for buyers who shop outside their gender
Deepen customer understanding: Use third-party data to identify insights for personalized messaging and increased engagement
Grow
Deepen customer understanding: Use third-party data to identify insights for personalized messaging and increased engagement
Basket analysis: Increasing customer lifetime value through targeted product bundling
Grow
Basket analysis: Increasing customer lifetime value through targeted product bundling
Persona building: Personalize your messaging for maximum return on your campaign investments
Grow
Persona building: Personalize your messaging for maximum return on your campaign investments
Driving customer loyalty: Identify, keep, and grow your most loyal customers
Retain
Driving customer loyalty: Identify, keep, and grow your most loyal customers
Increasing customer lifetime value: Upselling strategies
Grow
Increasing customer lifetime value: Upselling strategies
Reactivating lapsed customers: Retention and growth
Retain
Reactivating lapsed customers: Retention and growth
Welcome offer strategies: Using the Hub for analysis
Acquire
Welcome offer strategies: Using the Hub for analysis
Creating customer forms: Best practices
Enrich
Creating customer forms: Best practices
Connecting your MarTech stack with Lexer!
Enrich
Connecting your MarTech stack with Lexer!
Identifying win-back customers using the Second Last Order: Date attribute
Retain
Identifying win-back customers using the Second Last Order: Date attribute
Understanding customers' purchasing habits: Order Sequence filter
Grow
Understanding customers' purchasing habits: Order Sequence filter
Maximizing customer communications in Respond
Retain
Maximizing customer communications in Respond
Using Product Recommendation in the Hub to encourage repeat purchases
Grow
Using Product Recommendation in the Hub to encourage repeat purchases
Encouraging customer loyalty using birthday campaigns
Retain
Encouraging customer loyalty using birthday campaigns
Increasing customer lifetime value: Converting your one-time buyers into two-time buyers
Grow
Increasing customer lifetime value: Converting your one-time buyers into two-time buyers
Collecting zero-party data using Lexer Forms
Enrich
Collecting zero-party data using Lexer Forms
Measuring your data over time with Track
Enrich
Measuring your data over time with Track
UTM Creation Guidelines
UTM Creation Guidelines
UTM Creation Guidelines
Brand Assets
Brand Assets
Brand Assets
GTM guide to creating marketing materials with Lexer
GTM guide to creating marketing materials with Lexer
GTM guide to creating marketing materials with Lexer
How to use the Lexer Form Builder
How to use the Lexer Form Builder
How to use the Lexer Form Builder
Explore our standard integrations
Explore our standard integrations
Explore our standard integrations
Operating a CDP Practice LP
Operating a CDP Practice LP
Operating a CDP Practice LP
LP Sales Enablement
LP Sales Enablement
LP Sales Enablement
Video Training Courses LP
Video Training Courses LP
Video Training Courses LP
Purpose and Mission
Purpose and Mission
Purpose and Mission
Brand & Marketing LP
Brand & Marketing LP
Brand & Marketing LP
Stage 3 - QBRs and Customer insights
Stage 3 - QBRs and Customer insights
Stage 3 - QBRs and Customer insights
Client Onboarding Journey
Client Onboarding Journey
Client Onboarding Journey
Start your CDP Practice
Start your CDP Practice
Start your CDP Practice
Lexer Messaging
Lexer Messaging
Lexer Messaging
Pain point conversations
Pain point conversations
Pain point conversations
Lexer Ideal Customer Profile & Positioning
Lexer Ideal Customer Profile & Positioning
Lexer Ideal Customer Profile & Positioning
Referral Partner Program Overview
Referral Partner Program Overview
Referral Partner Program Overview
Demo Hub Guide
Demo Hub Guide
Demo Hub Guide