Adobe Analytics Implementation: Hacks You Don’t Know About

A few years ago, our developers rolled out Angular on a few key web pages—without consulting the web analytics team. The pageviews on some of the pages suddenly dropped to almost nothing. I bought two books on Angular to try to find a solution. Meanwhile, my manager stumbled on an alternative syntax for tracking pageviews […]

The post Adobe Analytics Implementation: Hacks You Don’t Know About appeared first on CXL.

A few years ago, our developers rolled out Angular on a few key web pages—without consulting the web analytics team. The pageviews on some of the pages suddenly dropped to almost nothing.

I bought two books on Angular to try to find a solution. Meanwhile, my manager stumbled on an alternative syntax for tracking pageviews in Adobe Analytics. As we found out, a similar alternative syntax also exists to track clicks (and anything else).

My first reaction was that both syntaxes were equivalent, but I could not have been more wrong. It also turned out that Adobe has barely documented the features you’re about to uncover.

1. Tracking pageviews

The classic syntax (Adobe’s recommendation)The overrides syntax (undocumented)
  pageName:"homepage",   channel:"home",

In both examples above, you pass the same information to Adobe. Looking at the tracking request URL in the browser dev tools Network tab, you can’t even tell which of the two syntaxes the web page uses.

The advantages of the overrides syntax emerge when you need to tag a single-page application (SPA). An SPA tends to load a page only once, then updates it partially to build the next page it needs to display. This produces the illusion of a new page but loads faster because fewer things change—there’s no need to reload the top navigation, the footer, etc.

Consider the following sequence:

  1. A visitor lands on an SPA, and the first page loads fully:


  1. The same visitor sees a second page:

s.pageName="products page 1";"products";

With Adobe Analytics, the problem is that your second pageview request contains s.prop1 again. That’s because the second page didn’t load as a new page—only an updated version. As a result, the s.prop1 is still there until a new page loads, or you reset it back to nothing:

s.pageName="products page 1";"products"; 
s.prop1=""; //resetting s.prop1 back to nothing

I don’t know about you, but remembering to clean all the props, eVars, events, contextData, product strings, etc., takes a lot of discipline. Someone is likely to forget one (or a few of them) in their tagging guides.

You could use s.clearVars before tracking your pageviews to reset most of your data points to nothing, but not contextData values. The s.clearVars has been around since at least 2016, but many companies still use ancient versions of the Adobe Analytics libraries.

Using the overrides syntax, there’s a more efficient, surgical way to clean these data points than s.clearVars that’s also supported by old Adobe Analytics libraries. Let’s revisit the second-page sequence but use the overrides syntax:

  1. A visitor lands on an SPA, and the first page loads fully:

  pageName : "home",
  channel  : "home",
  prop1    : "home"

  1. The same visitor sees a second page:

  pageName : "products page 1",
  channel  : "products"

Now, if you looked at the tracking requests for both pageviews, you would see that prop1 is in the first pageview request but not the second one. You no longer need to remember what to reset; you don’t need s.clearVars either.

The data points you declare inside the JSON that you pass as a parameter for your s.t() call have a scope that’s strictly limited to that s.t() call. With this overrides syntax, you declare private data points. Using the classic syntax, you declare public data points.

In the context of an SPA, Adobe Analytics remembers your public data points and forgets your private ones.

2. Tracking clicks and other page element interactions

As mentioned in the introduction, the overrides syntax exists for tracking clicks, too. You can also use the overrides syntax for any page element interaction, not just clicks.

The classic syntax (Adobe’s recommendation)The overrides syntax (undocumented)
  “click”, function(){
    s.linkTrackEvents=”None”;, “o”, “my button was clicked”);
  “click”, function(){
    s.linkTrackEvents=”None”;, “o”, “my button was clicked”,{prop2:”test”});

The method lets you track these page element interactions. It can take a fourth parameter, which is a JSON override object similar to the one for tracking pageviews.

The three-layer onion model

Any data point you declare inside the s-code (ancient) or the AppMeasurement Library (the new name for several years now) acts as a constant for all websites using that specific version of the Adobe Analytics library.

Details about your tracking servers, currency code, and character set are typical examples of such constants. This is a documented feature of Adobe Analytics implementations.

You can use the classic syntax after your Adobe Analytics library has loaded, making those data points public data points. You can check their values in the browser dev tools JavaScript console.

Typical examples are the page name, site section, sub-section, etc. There’s also an overrides syntax that lets you create private data points:

  1. In the Adobe Analytics library file: site-wide constants;
  2. In the page code public page-specific properties;
  3. Inside the s.t() and the calls: private tracking request specific properties.

For a non-SPA website, you’ve probably used only Layers 1 and 2 together. You can replace your page code properties with the overrides syntax (i.e. use Layers 1 and 3 instead). But with an SPA website, you should use all three layers, repurposing Layer 2 to declare only template-wide constants.

If you’re a fan of Functionalism, you may have categorized all web pages into page types. I would consider declaring the page type using a prop at Layer 2 with pathing enabled. (Functionalism is a topic for another blog post. Read the blog posts by June Dershewitz, and the original whitepaper by Gary Angel, Joel Hadary, and Paul Legutko.)

In SPA parlance, the developers refer to the content that updates a page template to create the illusion of new pages as fragments. When you go from page to page, the SPA loads fragments to update the page you were on before you clicked on that link. The page name probably changed as a result of that click, too.

You want to track that page name on Layer 3—inside the overrides JSON that you pass as an input parameter to the s.t() call because the page name is specific to the pageview tracking request.

And there you have it: Adobe Analytics on all three layers. Adobe has never documented how these layers work together.

A fourth layer for the onion model?

I have explained how you can declare data points as constants for your whole website, or a collection of websites when you declare them at a layer inside your Adobe Analytics library code.

The concepts of constants and default values are closely related. You might declare a data point on Layer 1, then redeclare the value for that data point on Layer 2 or 3. When you do, a given data point will be set to different values as the screen renders.

Generally speaking, the last value you pass to a data point will be the value you will see in your reports. The overrides syntax overrides all previous values the data point contained (should you redeclare its value in the JSON overrides object).

But this is not always true.

The Adobe Analytics library contains a function called s_doPlugins(). You need to set the s.usePlugins function to true, or the s_doPlugins() function will never execute.

At this point, you should be asking what difference it makes to declare a data point inside the library file versus inside or outside the function. It turns out that inside makes the data point read-only, and redeclaring it in Layers 2 or 3 makes no difference—the original value inside the s_doPlugins() function is the value you will see in the reports.

This happens because s.t() checks for the s.usePlugins flag, and if it’s set to true, it executes the s_doPlugins function that redeclares your data points. You could call this the fourth layer of the onion model:

  1. The Adobe Analytics library loads and declares the data points declared outside the s_doPlugins() function for the first time.
  2. The page code redeclares some of them.
  3. The s.t() function redeclares some of them in the JSON overrides object.
  4. The s.t() function executes and checks the s.usePlugins flag:
    • If it’s set to false, the reports show the values of the data points set inside the JSON overrides object in the s.t() function call.
    • If it’s set to true, the reports show the values declared inside the s_doPlugins() function.

Using s.t() for all your tracking needs

If you hadn’t guessed by now, I find strange ways to spend my free time. I once decided to deobfuscate the H.26 s_code.js Adobe Analytics library. I found the code for the s.t() and the functions that handle pageviews tracking and page element interactions tracking, respectively.

The function calls the s.t() function, which ultimately calls a deeper Adobe Analytics function called (I assume that mr stands for “make request” since that function builds the pixel URL for your s.t() and calls.)

If you’re looking for April Fools ideas to confuse your junior Adobe Analytics developer, you can make s.t() calls using the overrides syntax that behave just like calls. Here’s how:

  "click", function(){
      lnk : true,
      linkTrackVars : "channel,prop1,prop2,prop3",
      linkTrackEvents : "None",
      linkName : "Button was clicked",
      linkType : "o",
      pageName : dataLayer.pageName,
      channel :,
      prop1 : dataLayer.prop1,
      prop2 : dataLayer.prop2,
      prop3 : dataLayer.prop3


Adobe introduced callback support in AppMeasurement 1.8.0 in 2017. These are the s.registerPreTrackCallback() and s.registerPostTrackCallback() functions. They’re documented, and they let you execute code in response to a tracking request just before it fires, or right after it fired.

If you’re working with an older version of the Adobe Analytics library and need these callbacks, all is not lost, but what follows is not supported by Adobe—it requires modifying the code in the “do not modify” part of the library (which could void your support).

I’ve mentioned above that functions generate the tracking request and fire the HTTP request. The function contains this line of code:


  • im is an <img> tag element created on the fly. This object has a src property that is the URL of that <img> tag.
  • The rs is a string containing the tracking pixel URL. If you commented out that seemingly innocent command, the tracking requests stop firing altogether.

Setting the src property of an <img> tag triggers an HTTP GET request. You could call a custom JavaScript function before and/or after this line of code to support callbacks with older versions of the Adobe Analytics library code.

For even greater code decoupling, consider firing two distinct custom Javascript events—one before and one after the tracking request. Each of these custom JavaScript events can take a custom JSON object, which could be the same JSON you used with the overrides syntax (or a subset or superset of it).

document.body.dispatchEvent(new CustomEvent(
  detail:{},//optional JSON, can be your overrides JSON object
document.body.dispatchEvent(new CustomEvent(
  detail:{},//optional JSON, can be your overrides JSON object

Two things to remember (unless you want to generate infinite server calls and get fired):

  1. Never call s.registerPreTrackCallback() or s.registerPostTrackCallback() inside the s_doPlugins() function.
  2. Never call s.t() or inside the s.registerPreTrackCallback(), s.registerPostTrackCallback(), or functions.

Please note that more recent versions of Adobe Analytics support HTTP POST requests. Old versions of Internet Explorer only support URLs of up to 2,083 characters. This leads to truncation, and truncation leads to loss of data.

Since 2014, Adobe Analytics has supported switching from HTTP GET (i.e. using <img> tags to send the data to the Adobe servers) to HTTP POST (i.e. submitting a hidden form). This article does not cover creating callbacks for HTTP POST, but I’m sure that determined minds will find the HTTP POST equivalent of im.src=rs.


I believe that Adobe originally had a single method to track pageviews and page element interactions. Then, later versions of Adobe Analytics introduced a separate function for tracking these interactions, and so the function was born—and the s.t() was restricted to tracking pageviews.

I also believe that the overrides syntax was the original way of tracking; the page code came later on. Omniture, then Adobe, has had to ensure that upgrading the s_code.js file and, later, the AppMeasurement library code didn’t force clients to redo all their tagging. 

The latest and future versions of the Adobe Analytics library will continue to contain code that supports ancient implementations. I like the overrides syntax. I find it elegant, and it has worked very well for us, especially on our SPAs.

The post Adobe Analytics Implementation: Hacks You Don’t Know About appeared first on CXL.

Audience Segmentation: Where Do You Start?

As Peter Drucker famously wrote, “The aim of marketing is to know the customer so well the product or service fits them, and sells itself.” In conversion optimization, we talk about the importance of knowing our customers a lot. But we rarely talk about the process of strategically segmenting our audience so that our products […]

The post Audience Segmentation: Where Do You Start? appeared first on CXL.

As Peter Drucker famously wrote, “The aim of marketing is to know the customer so well the product or service fits them, and sells itself.”

In conversion optimization, we talk about the importance of knowing our customers a lot.

But we rarely talk about the process of strategically segmenting our audience so that our products and services can sell themselves.

What is segmentation?

Segmentation is the process of breaking a large audience down into smaller, more manageable chunks.

When you get a pack of Smarties, you don’t just tip the box back and eat them all at once (unless you’re a monster). Instead, you separate them by color so that you can, of course, eat the red ones last. That’s segmentation.

Why you need segmentation

Segmentation has many benefits. Like data segmentation, audience segmentation makes it easier to uncover optimization opportunities that you might not see when looking at aggregate data. The other core benefits of audience segmentation are:

  • Being able to assess the current value and potential value of your audience(s).
  • Strategically expanding your total addressable market (TAM). You can’t assume what’s true for your current audience is true for your current (and future) TAM.
  • Identifying new product development opportunities you might have otherwise overlooked.
  • Refining your brand positioning based on actual data instead of best guesses.

There are dozens of applications for segmentation. You can use segmentation to run smarter tests, launch more effective paid ads, send more compelling emails, etc. 

The problem(s) with segmentation

Segmenting a pack of Smarties is a bit more straightforward than segmenting your audience. It’s not as cut and dry as many marketers believe. It gets a bit complicated because:

  • There are a million ways to segment an audience. You can segment by geographic location, by product usage, by device, by interests, by activation channel, by where they went to school in 7th grade—you get the idea. How do you know which segmentation method is the most accurate? How do you know which method is the most valuable? What happens when segments compete with one another—how does the person get assigned? 
  • Everything and everyone is always changing. Not to get existential here, but humans aren’t static. They don’t exist in neat little packages that you can slap a cute avatar on and laminate for the office. The way people behave is changing, who people are is changing, your site is changing, your product(s) is changing, etc.
  • Targeting can be very difficult. Once you have your segmentation strategy in place, you need to assign people to the right segments. That can be difficult depending on your data structure and tech stack, especially if it’s siloed. Additionally, you now need to be able to target these segments via your activation channels. Sure, it’s simple enough to target women ages 24–35 earning over $100,000 a year in Atlanta, but what if you want to target fear-motivated, familiarity-seeking buyers?

3 core categories of segmentation

As mentioned, there are endless ways to segment your audience. Most fall into one of three categories, though: behavioral, demographic, or psychographic.

1. Behavioral

This is the category of segmentation you’re likely most familiar with. Behavioral segmentation divides people based on previous actions they’ve taken. 

It’s why Netflix recommends a weird amount of reality TV to me:

netflix recommended shows as an example of behavioral segmentation.

And why Amazon tries to entice me with books, exclusively:

amazon example of behavioral segmentation for recommended products.

And why Spotify won’t let me forget my punk rock youth:

spotify segmentation based on behavioral data.

You do X, you’re assigned to segment Y, and you receive personalization Z. Simple, straightforward, and quite common.

The major pros and cons of behavioral segmentation are:


  • Big data has made data collection seamless. With the right tool, from Google Analytics to Quantcast, marketers have access to much more data than they actually use.
  • It’s based on proven habits and behaviors.


  • It’s easy to generalize intent and the probability of repetition. For example, have you ever purchased a mattress, fridge, or expensive vacation—only to be pushed to purchase another, oh, three months later? 
  • Motivations and intent separate us. If you and I purchase the same business book, how much do we have in common besides that single purchase? Maybe you’re an aspiring small business owner who bought it for research purposes while I bought it for a colleague, for example.

2. Demographic

This is another category of segmentation you’re likely already familiar with. Demographic segmentation divides people based on physical and socioeconomic factors: age, location, gender, ethnicity, education level, income level, etc.

It’s why Starbucks recommends a store based on my current location:

demographic segmentation example based on location.

And why LinkedIn thinks I’d be interested in jobs posted by companies in Toronto that have hired quite a few Shopify (where I work) and University of Waterloo (where I went to school) alumni:

demographic segmentation example on linkedin.

And why Gymshark shows me recommendations for women’s clothing first:

demographic segmentation example on ecommerce site.

The major pros and cons of demographic segmentation are:


  • Similar to behavioral data, demographic data is readily available thanks to big data and third-party tools. It’s easy to access, and sorting is relatively binary.
  • It’s easy to target people based on their demographic data, especially with paid ad platforms.


  • Demographic segmentation is incredibly broad and makes a lot of assumptions. How much do you have in common with everyone in your zip code? How much does the man who is married with two kids and a six-figure job at 27 have in common with the man who is single with two roommates and a Led Zeppelin cover band at 27? 
  • Demographic segmentation relies on shallow, often temporary data. How much does someone change when they move from Wisconsin to Iowa? When Google announced the “death of demographic segmentation”, they used the concept of the “new moms” segment (i.e. women 20–35 with at least a high-school education and a middle-of-the-road income) as an example. But, in 2019, women are marrying and having children later, and men are taking on more active parenting roles. How does demographic segmentation account for gender fluidity? How does it account for freelancers whose income may vary widely from one year to the next?

3. Psychographic

This is the category of segmentation you’re likely less familiar with. Psychographic segmentation divides people based on beliefs, emotions, personality traits, motivations, intent, interests, lifestyle, worldviews, etc. It’s a bit harder to see, unaided.

Psychographic segmentation is often intertwined with brand, making it almost impossible to identify without confirmation from the company.

It’s why Chubbies includes their belief statements on their site:

chubbies belief statement that reflects psychographic segmentation.

And why Holstee’s corporate manifesto went viral:

example of company mission statement that went viral due to psychographic segmentation.

Actually, it’s why most things go viral within certain segments:

It’s also why appeals to emotion can be so effective:

example of psychographic segmentation on ASPCA homepage.

Where would CrossFit, veganism, and Bayesian statistics be without psychographic segmentation? Amirite?

Psychographic segmentation occasionally gets a bad rap. In fact, I’ve written an entire article on why segmenting based on the popular buyer modalities, which are based on personality traits, is a bad idea. It’s worth exploring, though, as long as you do so responsibly.

The major pros and cons of psychographic segmentation are:


  • You’ll get to the why behind the who and the what. You’ll get an understanding of unarticulated needs, desires, and motivations.
  • Psychographic is less sensitive to change over time compared to behavioral and demographic segmentation because it cuts closest to who people are as human beings. It’s very difficult to change someone’s beliefs, especially compared to surface-level things, like geography and current behavior.
  • Psychographic segmentation enables you to craft smarter, more compelling messaging. When expert copywriters talk about voice of customer copy, they’re referencing copy fueled by psychographic evaluation.


  • Without a psychographic survey or interviews, you won’t be able to rely on this segmentation method.
  • It’s more difficult to translate psychographic segmentation factors to those you can target in emails, ads, etc.
  • It’s very easy to half-ass psychographic segmentation (see the buyer modalities). The benefits are alluring, so it’s common to apply pseudoscience and pop psychology with reckless abandon instead of putting in the work required to pull it off.

Combine for best results

Alone, no segmentation category is perfect. For best results, you should combine all three to generate robust, data-driven segments that propel your marketing campaigns and experimentation program forward.

Machine learning is playing an increasingly large role in segmentation. (See this article, for example.) As with anything related to AI and machine learning, this does not negate the need for strategic marketing thinking.

It’s still up to you to set the segmentation strategy and decide how best to divide your audience, with or without a machine learning tool or algorithm at your disposal.

Regardless of how you approach segmentation, your strategy should solve for three things:

  1. Distinction. To be effective, your segments need to be distinct from one another.
  2. Targeting. To be effective, your segments need to be targetable on first- and third-party tools.
  3. Durability. To be effective, your segments need to be valuable throughout the entire lifecycle. For this reason, segments should connect to customer lifetime value.

Finally, when approaching segmentation, minimize the differences within your segments and maximize the differences between your segments.

How to get segmentation right

children segmenting candy by color.

The specifics of how to segment depend heavily on the application and context.

How you apply your segments to email, paid ads, social media, your site, your in-product experience, etc., will vary wildly. 

How Company A applies segments will differ from how Company B applies segments. It depends on a number of factors, ranging from their data warehouse to their TAM expansion objectives. 

There’s no prescribed, universally right way to apply it, unfortunately. What is universally important is that you have a strategy for how you select your segments.

Here are some principles to guide your application.

Start somewhere

Anything is better than nothing. It’s unlikely that you’re going to develop a fully formed segmentation strategy if you’ve never, well, tried segmentation. Just get started.

If you’re a startup with access only to basic data from Google Analytics and your CRM, start by looking at people who have made a repeat purchase versus people who haven’t. Or people in North America versus people in Asia. Or people who have visited the site before versus people who haven’t.

You’ll experiment your way into insights, which will inform smarter segmentation, which will lead to new insights, which will eventually lead you to a more meaningful strategy. You don’t need to jump into psychographic surveys and interviews on Day 1.

Focus on the need

There are no hard-and-fast rules for when you should start thinking about segmentation. Ask yourself three questions:

  1. Why am I segmenting my audience?
  2. What business need am I trying to solve through segmentation?
  3. How well do these segments serve that business need?

If you can answer all three, it’s a good time to start thinking about a segmentation strategy. Make sure there’s close alignment between the strategy and the application. It’s surprisingly easy to drift away from that business need as you move through this process.

Experimentation for experimentation’s sake is useless. So is segmentation, and personalization, and, well, pretty much anything. You end up doing the thing just to say you do the thing.

Constantly evolve

Much like experiment results, segments degrade over time. Segmentation strategies should be durable, but never static. This isn’t a one-and-done process that will serve the company for years to come. 

You have to change the way you segment, adjust your segmentation parameters, etc., on a regular basis. If not, there’s a good possibility you’ll end up making major business and marketing decisions based on out-of-date, unreliable data.

Expect to invest a lot of time and energy upfront, but also expect to invest in continuous maintenance—regular checks and balances.


When you speak to a crowd of people, your message will be more compelling to some than to others. Some people will “get” your introduction, some won’t. Some will think your joke is funny, some won’t. Some will respond to that emotional appeal, some won’t. 

Segmentation is what allows you to understand those differences. Instead of delivering one mediocre speech to everyone, segmentation allows you to deliver many perfect speeches to many specific audiences.

If you want your products and services to sell themselves, it’s not enough to know your customers. You’ll need to strategically segment those customers you know so well.

Here’s the step-by-step process:

  1. Define the business need you’re trying to solve with segmentation.
  2. Be aware of the imperfections of segmentation categories and the issues that come with each.
  3. Start somewhere—start anywhere! Even the simplest application is better than nothing. See what works and what doesn’t.
  4. Eventually, combine behavioral, demographic, and psychographic data to create a segmentation strategy.
  5. Constantly invest in the maintenance of your segmentation strategy. Evolve with your customers, your site, your product, and your industry. Nothing lasts forever.

The post Audience Segmentation: Where Do You Start? appeared first on CXL.