Lexer 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:
March 7, 2024
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