Tracking Customer Lifetime Value In Google Analytics


In marketing, customer lifetime value (CLV), also referred to as lifetime value (LTV), is a prediction of the value a customer will have over there lifetime with your company or brand. This is often estimate, or averaged, sometimes with complex formulas.

This topic has been thoroughly covered by some excellent posts, and several books,  so I don’t intend to regurgitate what’s already been written. My goal is to introduce another method of tracking CLV with Google Analytics.

Instead of estimating CLV with simple (or complex) formulas, I’ll have you recording the actual lifetime value of each and every customer by the end of this post.

Two Methods: Custom Dimensions and Custom Metrics

You might think that a value like CLV should be tracked as a custom metric, because it’s a number. And you’re right, partially. But there are some limitations and pitfalls to be aware of when using this method.

Custom dimensions can also be used to track CLV, and should be used in conjunction with custom metrics. Each option has benefits and drawbacks.

Custom Dimensions


  • Can be used with Data Import
  • Can reflect the CLV of a user at any time (not dependent on the data range of the report)
  • Easy to get a distribution of users by CLV


  • Can’t easily segment by users with greater than or less than a certain CLV
  • Can’t report the average CLV per channel, region, etc.

Ed Brocklebank of Metric Mogul has written an incredibly detailed and complete post on tracking CLV with custom dimensions. I highly recommend reading through it and setting those up.

However, there is still some benefits to be had by tracking CLV with custom metrics. That’s what I intend to show you.

Custom Metrics


  • Can be used to show average CLV of users
  • Can be used to show average CLV by segment (channel, region, etc.)
  • Can be used to segment users with greater than or less than a certain CLV


  • Can only report CLV for date range selected. If you have a long date range and a lot of traffic, your data is likely to be sampled

Create the Custom Metric

First things first – you’ll need to create the custom metric in the Admin of Google Analytics before you can start sending values to it. Under the Property column, click through to Custom Definitions > Custom Metrics and create a new custom metric for your CLV like below:

CLV custom metric

Write down the index of the custom metric, you’ll need that in the next step. The index is a number from 1 to 20, which tells Google Analytics where to store the value. If this is your first custom metric, it will be at index 1.

One single line of code

Whether you have Google Analytics hard-coded on your site or implemented through Google Tag Manager, the code required to track CLV with custom metrics is actually quite simple.

On the receipt page where you include your ecommerce tracking code, you need to include an extra line that sets the order value as a custom metric. With hard-coded Google Analytics, you’ll typically be sending the transaction and items details along with the pageview hit (with enhanced ecommerce), so you just need to update your pageview to include the custom metric.

clv code

If you’re using Google Tag Manager, you’ll just need to capture the order value with a variable. You may already be doing this, and you likely have the transaction details in the dataLayer. If that’s the case, you can create a dataLayer variable to pull out the order value like below:

order value

Then you can use that variable in whichever tag sends along the transaction (either a pageview tag or an event tag) by adding it to the Custom Metrics section under More settings, like below:


Now that you’re getting the order value as a custom metric, you’ll want that to be associated with a specific user. For that, you’ll need to track a unique ID for each user as a user-scoped custom dimension. My colleague Amanda Schroeder covered the basics of setting up custom dimensions in her post about using custom dimensions to define audiences as well as getting even more advanced by setting up a User ID View.

For the unique ID, you may be able to use a value from your database or CRM for the user.

Once you have those two pieces in place, you can create a custom report like this one:

CLV Report

Remember, the Customer Lifetime Value metric here only includes revenue that occurred during the date range selected. So if a user purchased prior to that period (or after) it won’t be included. I’ve also filtered the custom report shown above to include only rows where Customer Lifetime Value is greater than 0.

Jim Gianoglio is a Senior Analytics Consultant. He works with implementation, analysis and training of Google Analytics and Google Tag Manager. Before focusing on analytics, he led the SEO campaigns of Fortune 500 companies in the insurance, retail and CPG industries. Things you didn’t know about Jim: he’s biked from Pittsburgh to Washington DC in 41 hours, roasts coffee beans and has done voiceovers for TV commercials.

  • Rafael Mas

    Hey Jim.

    I have created a tag that is fired on the final step of checkout. There I can use a datalayer (transactionTotal) for capturing the transaction value. My tag is fired using a JS, like below:

    $(document).ready(function() {

    var metricValue = ‘transactionTotal’;

    ga(‘set’, ‘metric1’, metricValue);


    Is correct to use like that? I ain’t a developer so it’s kind of complicated for me doing that alone.

  • Jogesh

    Wow this post was great. Learning new things of GA.

  • Rafael Mas

    Hey Jim. I’ve successfully integrated the data from the datalayer of my ecommerce plataform with GTM. Now we are receiving data for the unique client and purchase total, having the same report as you. With that in mind, I’ve done more and captured other values in the datalayer such as: Category (product); Brand (product); payment type ; installments and Shipping method and have a full report. Thanks for bringing this to light!

    • Jim Gianoglio

      Glad I was able to help!

    • Jim Gianoglio

      Hi Rafael –

      For some reason, it looks like your previous comment never got posted (maybe because it had some code in it?). Either way, it looks like you got things working. Let me know if you have any other questions.

  • João Correia

    Hi Jim,

    What you are describing in this post as CLV is actually monetary value. CLV is the projected monetary value (forecast) of a customer or group of customers, monetary value is the total spend per customer. Knowing the CLV allows companies to make better decisions on how much they can spend to acquire a customer with profit. Making decisions on past spend is not accurate to how profitable a customer is going to be. Example: Customer A buys $100 one time and goes to a competitor, Customer B buys $10 a month for 4 years before going to a competitor.

    • Jim Gianoglio

      That’s great feedback, João – thanks!

      In hindsight, the title of the post and use of the term CLV was maybe not the best 😉 However, it is still valuable to know the actual monetary value of your users over time. For example, you may see that certain customers have spent a lot of money over time, over many frequent transactions. These are customers you may not need to spend a lot of money marketing to. Whereas another group of customers may display signs of “leaving.” These may be customers that are worth spending more to market to them.

      Of course, none of these decisions should be made in a silo, and there’s no one metric that will tell you what to do. So yes, knowing CLV (the predicted value of the customer over your future realtionship with them) is certainly valuable and important. But I’m a believer that more data is better (with some caveats). If you don’t have the data, you can’t do the analysis.

  • Gerard Rathenau

    Nice post Jim. I didn’t think about sending the transaction value as a custom metric.

    What is the advantage over a custom dimension like this in the visitor id datalayer?

    [{“visitorId”:”1558″,”visitorLoginState”:”Logged in”,”visitorType”:”Geen center”,”visitorLifetimeValue”:103.9,”

    • Jim Gianoglio

      I’d recommend doing it both ways (as a custom dimension and as a custom metric). Having it as a metric makes it easier to create segments of users based on how much they’ve spent over time (e.g. everyone who spent between $0 to $100, $100 to $500, etc.). That’s much harder to do when the value is in a dimension – you have to resort to some rather complex RegEx.

  • brett

    “For the unique ID, you may be able to use a value from your database or CRM for the user” – would a unique system account number be a breach of googles privacy terms?

    • Jim Gianoglio

      No – your unique system account number is acceptable in terms of the TOS regarding PII (personally identifiable information).

      The general rule of thumb I always recommend using is that if someone at Google is able to take the value you pass and connect it to a human being, then it’s PII. A perfect example of this is ecommerce reporting. You pass a transaction ID, that you are able to tie back to your actual customer (using data that is outside of GA). The transaction ID alone is not PII – Google doesn’t have the key to unlock that ID.

  • Gerard Rathenau

    One further Question Jim about your content below:

    If you’re using Google Tag Manager, you’ll just need to capture the order value with a variable. You may already be doing this, and you likely have the transaction details in the dataLayer. If that’s the case, you can create a dataLayer variable to pull out the order value like below:

    Could you measure the variables transactionTotal and revenue with a dataLayer variable as custom metric? (hit level currency)

    • Jim Gianoglio

      I’m not sure I understand your question, Gerard. Can you clarify?

      • Gerard Rathenau

        Yes, Jim:

        I’ve made this revenue variable (see attachment)

        I’ve set up a custom metric for customer value (see attachment)

        I’ve set up a UA-tag with Enhanced E-commerce. I’m sending it with the trigger window ready. Is that a problem to send a custom metric to UA?

  • Konrad

    Hi Jim! Nice and simple – just how I like it. Could You please advice what to do if You have multiple currency transations? Should I use custom dimension to extract the currency? How Would I assosiated it with a transaction?


  • Hakukonekeisari

    Thousand thanks! This was really helpful for e-commerce stores.

Contact Us.


24 S. 18th Street, Suite 100,
Pittsburgh, PA 15203

Follow Us



We'll get back to you
in ONE business day.