Javascript Tag basics

Enrich your customer data

The Lexer Javascript Tag allows you to combine digital customer behavior with purchase and email data for a true, 360 degree view of your customer.

The Lexer Tag on your website facilitates individual analysis of a customer’s on-site behaviours. All attributes that are created via the tag can be searched, analyzed, and combined with first-party data, and then segmented.

This means real humans, not cookies!

In this article, we’ll discuss how the Javascript Tag works, its benefits, and the “out of the box” attributes that it can create, before wrapping up and talking through some next steps.

Why you should use the Lexer Javascript Tag

Between privacy concerns and depreciating accuracy, the third-party cookie is on the way out, putting pressure on marketers and tech providers to shift to other alternatives.

Lexer’s zero-party data solution is the Lexer Tag, and at Lexer we’re only interested in real people we can identify, not cookies, and the Lexer Tag specializes in just that! As soon as someone identifies themselves on your channels, we track and connect their digital behaviors to their profile in the Lexer Hub.

Note
Tag data is restricted due to changes in browser policies, which comply with new security and privacy standards. We try our best to capture as much user data as possible, but users who have ad blockers or use browsers like Safari, for example, restrict what data we can collect.

Implementing the Lexer Javascript Tag

The Javascript Tag is straightforward to implement and can be embedded in the code of your website or inside of a tag manager, for example, Google Tag Manager. It’s a two-step process:

  1. Lexer scope and configure the Tag bespoke to you.
  2. You and your team implement the Tag on your website.

The Javascript Tag works by capturing customer data, such as the number of seconds it took the customer to checkout in their last session, present on your website’s existing dataLayers. This data is identified when we scope your website. If there is no current dataLayer identified on site when we are scoping, then we make dataLayer recommendations according to Google Enhanced Ecommerce standards to gather the data.

This data is then sent to Lexer through a Payload that can map to a customer profile through an identifiable action (i.e. newsletter subscription, account login, account registration, transaction, etc.) enriching your existing customer data.

Out of the box attributes

When the Lexer Tag is embedded into your website it collects your customers’ activities in an action or manner specified by you from one of the 18 “out of the box” attributes listed below. Each of these is fully customizable to your use case and requirements. These attributes capture first-party data from the customers’ interaction on your website once they are linked.

The Lexer Javascript Tag is not designed to support web analytics and is strictly focused on recording actions that can be linked to an identifiable customer or prospect.

Attribute name Description Example value
Categories viewed A list of all the product categories viewed by a customer while on site. T-shirts
Date of last visit The date of the customers last visit to your website. "2021-05-31T00:00:00.140Z"
Dates visited A list of all the dates the customer visited your site. "2021-05-31T03:42:14.838Z"

"2021-05-31T03:44:33.829Z"
Device used The type of devices the customer used to browse your website. Desktop
Did complete conversion A flag to say that the customer did checkout. True
Did start conversion A flag to say that the customer started the checkout journey. True
Pages viewed to convert The number of pages the customer viewed to checkout in their last session. 5
Products added to cart A list of the products added to the customers cart while on site. Data Punk t-shirt
Products removed from cart A list of the products removed from the customers cart while on site. Data Maiden t-shirt
Products viewed A list of all the products viewed by the customer while on site. Data Rockstar t-shirt
Submitted survey Profiles that have submitted a response to any of the surveys you have created within Lexer. True
Referrer URL The site responsible for the visit - i.e. the customer clicked on a Facebook post. https://www.google.com
Time spent to convert The number of seconds it took the customer to checkout in their last session. 200 seconds
UTM campaign The name of the promotion or campaign that brought a customer to your site.
Helpful for understanding what campaigns customers are engaging with.
EMAIL_CAMPAIGN_TSHIRTS
UTM content The specific content that brought the customer to your site.
Helpful for understanding the type of content a customer is willing to click on.
LogoLink
UTM medium The medium that brought the customer to your site, such as social or email.
Helpful for understanding how a customer saw your link.
Email
UTM source The external site that brought the customer to your site, such as Facebook or Amazon.
Helpful for understanding where a customer saw your link.
Email
UTM term The search terms that brought the customer to your site.
Helpful for understanding ROI on paid keywords or informing keywords to put spend behind.
Shoes

Auto-tracking

The Lexer Javascript Tag automatically tracks several events upon deployment. These include:

Device used: Did the customer browse on a Mobile, Tablet, or Desktop device?
Time spent to convert: How long did the customer spend on the site?
Referrer URL: The domain of the site the customer came from, only supported on some browsers.
UTM codes: How did the customer land on my site?

Lexer tip!
Remember, identity is everything!Lexer is interested in enriching profiles in the CDP. Because of this we will only send browsing behaviour to the platform once a user is identified. No identification, no tag data.

Conversion

At the point of a customer’s conversion, you are able to send all captured data to Lexer by employing the [.code]lxt('converted')[.code] command. This could happen when a customer makes a final action on your site, like completing the purchase of a product.

Adding Lexer to your CORS policy

CORS, or Cross-Origin Resource Sharing, is an essential security feature that lets heaps of resources (e.g., fonts, JavaScript, etc.) on a web page be requested from another domain. You'll need to add * lexer.io to your CORS policy to allow your website to communicate with Lexer. For more information about CORS, you can refer to this comprehensive guide by Mozilla: Cross-Origin Resource Sharing (CORS).

Follow these steps to add Lexer to your CORS policy:

  1. Locate your server configuration file: This will be specific to your server setup. It could be an [.code].htaccess[.code] file for an Apache server, a [.code]nginx.conf[.code] file for Nginx, or a [.code]web.config[.code] file for Microsoft servers.
  2. Add a CORS policy: You will need to add or update a CORS policy in this file. The exact syntax will depend on your server, but in general, you will need to add a line that specifies [.code]*lexer.io[.code] as an allowed origin. For example, in an Apache server, you might add: [.code]Header set Access-Control-Allow-Origin "* lexer.io"[.code]
  3. Restart your server: After saving your configuration file, you'll need to restart your server for the changes to take effect.
Please note

• These steps might vary depending on your server setup. Always consult your server's documentation or seek advice from a qualified professional if you're unsure.

• The above steps and code snippets are illustrative and might not exactly match your server setup. Please consult your web developer or IT department before implementing changes to your CORS policy.

UTM codes

Urchin Tracking Module (UTM) codes are snippets of code attached to the end of a URL. They allow us to track data like traffic sources or campaign click names.

However, they don’t stop there. If you can include a UTM code in your URL, Lexer can be configured to track it.
As an example, you can append the email address of your customer to the URL when they click on an email, bumping up your identification rate.

For example:

[.code]www.yoursite.com/category/product?utm_campaign=campaignName&utm_source=newsletter&utm_email=myname@email.com[.code]

Implementation FAQs

What is a dataLayer?

A JavaScript object that collects data on your website in a standardized way. This data is dynamic depending on the page being viewed. A dataLayer is the most robust way to pass data to the Lexer Tag.

Why do we need a Tag Management System (TMS)?

A TMS allows you to deploy and manage tags on your site without relying wholly on IT. It removes the need to hard code anything into your website. Whilst a TMS isn’t necessary for deploying the Tag, it streamlines the process from implementation to QA.

What can the Tag track?

The Lexer Tag can track any data that you surface in the dataLayer. The Tag is told what data to capture by the dataLayer path you specify for your variable.

If there is a new data point you would like to capture and it doesn’t have a corresponding Lexer attribute, get in touch with your Solutions Lead.

Next steps

Now you know what the Lexer Javascript Tag is, its benefits, and how it can be implemented. The following Tag articles in this section expand further on the initial setup and how the dataLayer can be configured with Shopify.

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