# Custom dimensions for calculating customer lifetime value

Calculating LTV and [building the GA4 customer lifetime value report](https://github.com/littledata/helpcenter-content/blob/main/posts/lifetime-value-in-ga4/README.md) is essential for ecommerce businesses, but it can be difficult without the right analytics setup.

Littledata makes this easier for Shopify stores, and especially for subscription businesses, by adding custom dimensions to Google Analytics.

In addition to the dimensions below, Littledata tracks [subscription orders from any checkout](/sources/shopify/tracking-subscription-orders-in-the-shopify-checkout.md) and allows the LTV of these orders to be tied back to marketing campaigns.

## Custom event parameters

For all the ecommerce events from the checkout onwards, we send the following user parameters to help you segment explorations, build audiences and analyze user behavior:

| **Parameter**               | **Description**                                                                                                                | **Scope** |
| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | --------- |
| lifetime\_revenue\_ld       | Total of revenue from current and all previous purchases for that customer on Shopify                                          | User      |
| purchase\_count\_ld         | Count of current and all previous purchases for that customer                                                                  | User      |
| last\_transaction\_date\_ld | Date of customer's last order                                                                                                  | User      |
| shopify\_customer\_id\_ld   | Customer ID as used on Shopify                                                                                                 | User      |
| littledata\_client\_id      | Client ID: the cookie identifier Google uses to group events by user                                                           | User      |
| affiliation                 | A comma-separated list of order tags. Untagged orders use Shopify                                                              | Event     |
| store\_name                 | The name of the Shopify store generating the event. Useful when you have multiple country stores feeding into one GA property. | Event     |
| app\_name                   | The app name that generated the order (fallback on app ID).                                                                    | Event     |

{% hint style="info" %}
User parameter naming was changed as of August 2023 to comply with GA4's 24 characters limit.
{% endhint %}

## Automatic Custom Dimensions in GA4

In Google Analytics 4, each custom dimension that you wish to use in any report must be first configured based on user parameters that Littledata sends. One property can have up to 25 custom dimensions.

Littledata automatically sets up following custom dimension in your Google Analytics property

| Custom dimension      | Description                                                                      |
| --------------------- | -------------------------------------------------------------------------------- |
| Lifetime Revenue      | Total revenue of current and all previous purchases for that customer on Shopify |
| Purchase Count        | Count of current and all previous purchases for that customer                    |
| Last Transaction Date | Date of customer's current / last order                                          |
| Shopify Customer ID   | Customer ID as used on Shopify                                                   |
| App Name              | Name of the app on which the order was made (fallback on app ID)                 |
| Affiliation           | A coma-separated list of order tags. Untagged orders use Shopify                 |

## Setting up a GA4 custom dimension

If you want to set up further custom dimensions based on the above event parameters, follow these steps.

**Step 1**

Go to Configure > Custom definitions > Create custom dimensions

![](/files/73527HyH0BJbxDocdJBX)

**Step 2**

Name your dimension, select ***User*** scope, and select the desired user property from the drop down menu

![](/files/sGOM7rexKTPxQS7TCWq0)

You can now start using this custom dimension in the standard reports as well as in custom reports from the Explore section.

### Sample use case

In order to use Lifetime Value to evaluate the performance of various marketing campaigns you should create user [segments based on the lifetime spend](https://github.com/littledata/helpcenter-content/blob/main/posts/lifetime-value-in-ga4/README.md#what-is-the-best-way-to-use-ltv-provided-by-littledata), the parameter provided by Littledata

Here we'll provide the example of creating audiences based on the last purchase date and number of orders of the customer:

Using a segment in Google Analytics you can create (and export as audience) a segment that includes all users with the custom dimension:

* `last_transaction_date_ld`
* `purchase_count_ld`

You then can use that segment to [retarget them on Google Ads](/integrations/google-ads/shopify-to-google-ads.md).

This is an example for users that have purchased only once in the last month:

![](/files/eYQW60HscAubwBJ8tWS6)

{% hint style="info" %}
Since the last transaction date is sent as custom dimension, you will need to a regular expression to match the date
{% endhint %}

## Further reading

* [How our Recharge connection works with your Google Analytics setup](/sources/recharge/how-it-works-recharge-to-google-analytics-connection.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.littledata.io/google-analytics/conversions/customer-lifetime-value-google-analytics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
