Cohort Analysis - LTV - LTV by Acquisition Channel with Python (incomplete)

Cohort analysis is a subset of behavioral analytics that looks at users by groups to find insights. The most common way to group users is by acquisition date. This analysis opens doors to insights about retention rate, customer lifetime value, campaign performance, marketing channel performance.

Data Source

The code below is written for Shopify data, but you can replicate that with other sources of data, with minor adjustments. Also, Google Analytics data is also critical to get the "acquisition channel" piece.

Disclaimer

When I wrote this code, I downloaded the order data from Shopify into one folder. There are Shopify APIs, which allow you to accomplish the data extraction step a bit quicker, and I'll cover that in another post.

Understand the data

I'll skip the data preparation step, but you can still find the code needed for this step in the code file. It's up to your company's practice, but in my current company, I just consider orders made through online channels, besides, I need to remove marketing orders, wholesale and B2B orders, return/refund orders, and canceled orders. The purpose of this is to have a data set that reflects general customer behavior.

Last updated