How to Make a Sankey Diagram in Google Analytics with AI

Cody Schneider

A Sankey diagram is one of the best ways to visualize the flow of users through your website. Instead of staring at tables of data, you can instantly see the paths people take, where they drop off, and which journeys lead to conversions. But when you look inside your Google Analytics 4 property, you’ll quickly realize there’s no "Create Sankey" button. This article breaks down exactly how to get around that limitation. We’ll cover the old-school manual methods and then show you the modern, AI-powered way to get it done in seconds.

What is a Sankey Diagram & Why Use It for GA4 Data?

Think of a Sankey diagram as a flow map. It shows how a quantity - in this case, your website users - moves from one point to another. The width of the connecting lines (or "nodes") is proportional to the flow rate. A thick line means lots of users took that path, a thin line means fewer did.

While Google Analytics has its own "Path exploration" report, a Sankey provides a much clearer and more intuitive view of the customer journey. It excels at answering questions like:

  • What are the most common paths users take after landing on my homepage? See exactly where your main entry traffic navigates next.

  • Where is the biggest drop-off point in my checkout process? Identify the specific page where you're losing the most potential customers.

  • How do users from different marketing channels behave? Visualize whether visitors from organic search follow a different path than those from paid ads.

  • Do users who view the "/pricing" page end up converting? Connect user behavior to real business outcomes.

In short, a Sankey turns abstract pathing data into a compelling visual story, making it far easier to spot opportunities and fix leaks in your funnel.

The Challenge: No Native Sankey Diagram in GA4

Google Analytics 4 is powerful, but it's not a dedicated data visualization tool. Its primary job is data collection and standard reporting. The native "Path exploration" tool is Google’s attempt at showing user flow, but it can be clunky, hard to read, and difficult to customize. It draws paths from either a starting point or an ending point, but not both at once in the simple, elegant way a Sankey does.

This limitation forces a choice: you either have to settle for the standard GA4 reports or get the data out of Analytics and build the visualization yourself. For years, this meant tedious manual work or relying on a technical team member to write code. Let's look at those methods first.

Method 1: The Manual Approach (Using Google Sheets)

This is the classic DIY method. It's free and uses familiar tools, but it requires a lot of patience and manual data wrangling. If you have a free afternoon and enjoy working in spreadsheets, this is a viable option.

Step 1: Get Your Path Exploration Data Out of GA4

First, you need the raw data. Inside GA4, navigate to the Explore section and create a new Path exploration report.

  1. Set your starting point. This could be an event like session_start or users landing on a specific page.

  2. The report will generate a flow diagram. This isn't our final product, but it contains the data we need.

  3. Above the visualization, you'll see a table showing the different paths (e.g., Step +1, Step +2, etc.).

  4. In the top right corner, click the "Share & Export" icon and choose "Download File > CSV" or "Google Sheets." Getting it into Google Sheets is often easiest for the next steps.

You’ll end up with a sheet that lists sequences of user actions and the corresponding number of users for each path.

Step 2: Restructure the Data for a Sankey Chart

This is the most time-consuming step. A Sankey chart requires your data to be in a specific three-column format: Source, Target, and Weight (the number of users making that journey).

Your exported GA4 data won't look like this. It will look like a sequence: Homepage >> About Page >> Contact Page with a user count of, say, 500.

You need to manually break down each path into individual steps:

  • Row 1: Source = Homepage, Target = About Page, Weight = 500

  • Row 2: Source = About Page, Target = Contact Page, Weight = 500

You have to do this for every single path in your export. If a page appears in multiple paths, you'll need to carefully sum the weights using formulas like SUMIF to get the total flow between any two pages. This process of cleaning, transforming, and aggregating the data can easily take hours, especially if you have a high-traffic website with many possible user journeys.

Step 3: Build the Chart in Google Sheets

Once your data is finally structured in those three perfect columns, building the chart is relatively simple:

  1. Select your three columns of data (Source, Target, Weight).

  2. Go to Insert > Chart.

  3. In the Chart Editor, under Chart type, scroll down to the "Other" section and select Sankey chart.

Google Sheets will create the visualization. You can make some minor style adjustments, but it's not the most flexible tool. Plus, this chart is completely static. If you want to see data for a different date range, you have to repeat the entire export and data re-structuring process all over again.

Method 2: The Semi-Automated Approach (Using Python)

For those with technical skills, you can automate this process by pulling data directly from the GA4 API using a Python script. Libraries like Plotly and Plotly Express have excellent functions for creating interactive Sankey diagrams. The typical workflow looks like this:

  1. Set up authentication for the Google Analytics Data API.

  2. Write a script to query the API for pathing data (similar to what the Exploration report provides).

  3. Use a library like Pandas to process and structure the data into the Source-Target-Weight format.

  4. Pass this structured data to Plotly to generate the Sankey diagram.

Pros: This is repeatable and highly customizable. Once the script is written, you can re-run it anytime.

Cons: It requires significant technical expertise. You need to be comfortable with APIs, authentication, and programming. It is not an option for the average marketer, founder, or analyst who just wants a quick answer.

Method 3: The Instant AI Approach (The Modern Way)

Instead of manually wrangling data or writing code, modern AI-powered analytics tools eliminate this difficult middle step completely. They connect directly to your data sources and allow you to simply ask for the visualization you want in plain English.

Think of it as having a data analyst on your team. You wouldn't hand them a CSV and tell them which cells to copy and paste, you'd just ask, "Can you show me a visual of user flow from our landing pages?" That's exactly how this approach works.

Step 1: Connect Google Analytics (A One-Time Step)

Modern tools use secure, one-click integrations. You simply authenticate your Google account, select the GA4 property you want to analyze, and the connection is made. There are no API keys to copy, no code to write, and no complex setup. The tool handles syncing your data in the background.

Step 2: Describe the Chart You Want to See

This is where the process becomes transformative. Instead of clicking through menus or manipulating spreadsheets, you just type your request into a chat interface. For example:

  • "Show a Sankey diagram of user flow from the homepage to the top 5 pages for last month."

  • "Create a Sankey chart visualizing the user journey for mobile traffic that started with our spring marketing campaign."

  • "Build a Sankey diagram of how users navigate our checkout process, starting from the cart page."

The AI understands the intent behind your question, queries the live GA4 data, performs all the necessary transformations automatically, and generates the visualization.

Step 3: Get Your Visualization Instantly and Ask Follow-up Questions

Within seconds, a clean, interactive Sankey diagram appears on your dashboard. Unlike the static image from Google Sheets, this visualization is live and connected to your data. The real power comes from the ability to iterate and drill down conversationally.

After seeing the initial chart, you might ask:

  • "Okay, now filter this for users from the United States only."

  • "Break this down by device category."

  • "Why is the drop-off rate from the shipping page so high?"

This conversational approach allows you to explore your data at the speed of thought, uncovering insights that would have been buried under hours of manual work with the older methods.

Final Thoughts

Creating a Sankey diagram from your Google Analytics data offers a powerful way to understand user behavior. While GA4 doesn't provide this chart out-of-the-box, you can build one by manually reformatting exported data in spreadsheets or by writing custom code, though both methods are time-consuming and cumbersome. The most efficient and accessible route is to use an AI-powered analytics platform that translates your natural language requests directly into live, interactive visualizations.

Eliminating tedious, manual reporting is exactly why we built Graphed. After a one-click connection to your Google Analytics account, you can create a Sankey diagram (or any other chart) just by describing it. No more fighting with CSV files or trying to remember spreadsheet formulas. We built Graphed to be the data analyst on your team, giving you back the time to focus on making smart decisions instead of wrestling with reports.