Sankey Diagram Development for Website Flow Visualization

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Showing 1 of 1All 2062 services
Sankey Diagram Development for Website Flow Visualization
Medium
from 1 day to 3 days
Frequently Asked Questions

Our competencies:

Development stages

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1362
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1253
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    958
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1190
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    931
  • image_bitrix-bitrix-24-1c_fixper_448_0.webp
    Website development for FIXPER company
    949

During a sales funnel analysis on an e-commerce site with 50,000 monthly sessions, we found that 40% of traffic went to the catalog page but did not proceed further. Standard reports showed only a 2.5% conversion rate at that stage but didn't explain why. A Sankey diagram helped reveal that users from paid ads often jumped directly to product pages, bypassing the catalog, and converted three times more often than organic users. After reallocating the budget, conversion increased by 20%. This tool visualizes every transition between pages, channels, or stages. Without such visualization, you cannot see exactly where you lose traffic.

Why Standard Funnels Don't Show the Full Picture

Standard funnel reports show conversion at each step but don't show where the most valuable users come from or where they go. The Sankey diagram solves this by displaying all flows between nodes. For example, you can see that users from paid ads often go directly to product pages, bypassing the catalog, and make purchases three times more often than organic users. This allows you to reallocate budget and increase ROI. Sankey diagrams are 3x more effective than standard funnels in identifying bottlenecks.

How the Sankey Diagram Improves Analytics

The Sankey answers questions invisible in tables: where do high-converting users come from, which path leads to maximum LTV, where is the most traffic lost. We use drill-down — clicking on a node reveals its internal structure, allowing deep exploration without stopping. In product analytics, the Sankey shows which channel combinations (organic → product → cart) lead to purchase and which lead to abandonment. For cyclic data (users looping), we use d3-sankey-circular.

What Drill-Down Provides

Drill-down allows you to detail the selected node by revealing its internal structure. For example, clicking on the 'Cart' node shows which sources users came from and what actions they took next. This is especially useful for deep analysis of funnels with many stages.

Comparison of Standard Funnel vs. Sankey Diagram

Characteristic Standard Funnel Sankey Diagram
Number of paths displayed Only sequential steps All possible routes
Visualization of drop-offs Does not show Shows flow width
Interactivity Limited Drill-down, filtering, tooltip
Readability with 100+ nodes Impossible Works with optimization
Traffic source comparison Requires separate reports Single unified map

Technical Implementation of Sankey on React

We use a modern stack: React 18, TypeScript, d3-sankey. This ensures smooth rendering even with 10,000+ connections – according to d3-sankey official documentation.

Installation and Dependencies

npm install d3-sankey d3
npm install --save-dev @types/d3-sankey

Data Structure

Data for the Sankey consists of nodes and links. Each link contains source, target, and value. Example for an e-commerce funnel:

interface SankeyNode {
  id: string;
  label: string;
  color?: string;
}

interface SankeyLink {
  source: string;  // source node id
  target: string;  // target node id
  value: number;   // flow volume
}

interface SankeyData {
  nodes: SankeyNode[];
  links: SankeyLink[];
}

// Example: e-commerce funnel
const data: SankeyData = {
  nodes: [
    { id: 'organic', label: 'Organic' },
    { id: 'paid', label: 'Paid Ads' },
    { id: 'direct', label: 'Direct' },
    { id: 'catalog', label: 'Catalog' },
    { id: 'product', label: 'Product Page' },
    { id: 'cart', label: 'Cart' },
    { id: 'checkout', label: 'Checkout' },
    { id: 'purchase', label: 'Purchase' },
    { id: 'exit', label: 'Exit' },
  ],
  links: [
    { source: 'organic', target: 'catalog', value: 4200 },
    { source: 'organic', target: 'product', value: 1800 },
    { source: 'paid', target: 'catalog', value: 2100 },
    { source: 'paid', target: 'product', value: 3400 },
    { source: 'direct', target: 'catalog', value: 900 },
    { source: 'catalog', target: 'product', value: 5600 },
    { source: 'catalog', target: 'exit', value: 3100 },
    { source: 'product', target: 'cart', value: 2900 },
    { source: 'product', target: 'exit', value: 4800 },
    { source: 'cart', target: 'checkout', value: 1600 },
    { source: 'cart', target: 'exit', value: 1300 },
    { source: 'checkout', target: 'purchase', value: 1100 },
    { source: 'checkout', target: 'exit', value: 500 },
  ],
};

Component with Tooltip and Interactivity

Our React component renders SVG using d3. It includes:

  • Smooth rounded paths
  • Tooltip on hover over nodes or links
  • Color encoding by node (Tableau10 scale)
  • Adaptive width and height
import { useEffect, useRef } from 'react';
import * as d3 from 'd3';
import { sankey, sankeyLinkHorizontal, sankeyLeft } from 'd3-sankey';

export function SankeyDiagram({ data, width = 800, height = 500 }: { data: SankeyData; width?: number; height?: number }) {
  const svgRef = useRef<SVGSVGElement>(null);
  const margin = { top: 20, right: 20, bottom: 20, left: 20 };

  useEffect(() => {
    if (!svgRef.current) return;

    const svg = d3.select(svgRef.current);
    svg.selectAll('*').remove();

    const iw = width - margin.left - margin.right;
    const ih = height - margin.top - margin.bottom;

    // Prepare data for d3-sankey
    const nodeMap = new Map(data.nodes.map((n, i) => [n.id, { ...n, index: i }]));

    const sankeyData = {
      nodes: data.nodes.map(n => ({ ...n })),
      links: data.links.map(l => ({
        source: data.nodes.findIndex(n => n.id === l.source),
        target: data.nodes.findIndex(n => n.id === l.target),
        value: l.value,
      })),
    };

    const sankeyLayout = sankey()
      .nodeWidth(20)
      .nodePadding(12)
      .nodeAlign(sankeyLeft)
      .extent([[0, 0], [iw, ih]]);

    const { nodes, links } = sankeyLayout(sankeyData as any);

    const colorScale = d3.scaleOrdinal(d3.schemeTableau10);

    const g = svg.append('g').attr('transform', `translate(${margin.left},${margin.top})`);

    // Tooltip
    const tooltip = d3.select('body').append('div')
      .style('position', 'absolute')
      .style('display', 'none')
      .style('background', 'rgba(0,0,0,0.8)')
      .style('color', '#fff')
      .style('padding', '8px 12px')
      .style('border-radius', '4px')
      .style('font-size', '13px')
      .style('pointer-events', 'none');

    // Links
    g.append('g')
      .selectAll('.link')
      .data(links)
      .join('path')
      .attr('class', 'link')
      .attr('d', sankeyLinkHorizontal())
      .attr('fill', 'none')
      .attr('stroke', (d: any) => colorScale(String(d.source.index)))
      .attr('stroke-width', (d: any) => Math.max(1, d.width))
      .attr('stroke-opacity', 0.4)
      .on('mouseover', (event, d: any) => {
        d3.select(event.currentTarget).attr('stroke-opacity', 0.7);
        tooltip
          .style('display', 'block')
          .style('left', `${event.pageX + 12}px`)
          .style('top', `${event.pageY - 28}px`)
          .html(`<strong>${d.source.label} → ${d.target.label}</strong><br/>${d3.format(',.0f')(d.value)} users`);
      })
      .on('mouseout', (event) => {
        d3.select(event.currentTarget).attr('stroke-opacity', 0.4);
        tooltip.style('display', 'none');
      });

    // Nodes
    const nodeG = g.append('g')
      .selectAll('.node')
      .data(nodes)
      .join('g')
      .attr('class', 'node');

    nodeG.append('rect')
      .attr('x', (d: any) => d.x0)
      .attr('y', (d: any) => d.y0)
      .attr('width', (d: any) => d.x1 - d.x0)
      .attr('height', (d: any) => Math.max(1, d.y1 - d.y0))
      .attr('fill', (d: any) => colorScale(String(d.index)))
      .attr('rx', 3)
      .on('mouseover', (event, d: any) => {
        tooltip
          .style('display', 'block')
          .style('left', `${event.pageX + 12}px`)
          .style('top', `${event.pageY - 28}px`)
          .html(`<strong>${d.label}</strong><br/>Volume: ${d3.format(',.0f')(d.value)}`);
      })
      .on('mouseout', () => tooltip.style('display', 'none'));

    // Labels
    nodeG.append('text')
      .attr('x', (d: any) => d.x0 < iw / 2 ? d.x1 + 6 : d.x0 - 6)
      .attr('y', (d: any) => (d.y0 + d.y1) / 2)
      .attr('dy', '0.35em')
      .attr('text-anchor', (d: any) => d.x0 < iw / 2 ? 'start' : 'end')
      .attr('font-size', 12)
      .attr('fill', '#374151')
      .text((d: any) => d.label);

    return () => { tooltip.remove(); };
  }, [data, width, height]);

  return <svg ref={svgRef} width={width} height={height} />;
}

Data Preparation: SQL Aggregation

Data for Sankey is usually aggregated from an event stream. Example SQL query for a site funnel (sequential page transitions within a session):

WITH ranked_events AS (
  SELECT session_id, page_type,
         LAG(page_type) OVER (PARTITION BY session_id ORDER BY created_at) AS prev_page_type,
         ROW_NUMBER() OVER (PARTITION BY session_id ORDER BY created_at) AS step
  FROM page_views WHERE created_at > NOW() - INTERVAL '30 days'
)
SELECT COALESCE(prev_page_type, 'entry') AS source,
       page_type AS target,
       COUNT(*) AS value
FROM ranked_events
WHERE prev_page_type IS NOT NULL OR step = 1
GROUP BY 1, 2
HAVING COUNT(*) > 50
ORDER BY value DESC;

This query gives a transition table with user counts. For large data volumes, we use pre-data aggregation with Materialized Views or triggers.

Layout Configuration: Which Algorithm to Choose?

d3-sankey supports several node alignment algorithms. The choice affects diagram readability.

Algorithm Description Use Case
sankeyLeft Nodes align to the left of the level Funnels with fixed step order
sankeyRight Align to the right Graphs with leaf nodes on the left
sankeyCenter Align to the center of the graph Acyclic graphs with no clear direction
sankeyJustify Leaf nodes are pushed to the right General case

For cyclic data, we use d3-sankey-circular or pre-break cycles.

What's Included in the Work

  • Analytics: studying your data structure, identifying key metrics and integration points.
  • Design: developing layout, choosing layout algorithm, prototyping interactions.
  • Implementation: coding the component in React/TypeScript, setting up backend for data aggregation.
  • Documentation: describing the component API, usage and customization instructions.
  • Testing: validation on real data, load testing (up to 100,000 links), optimization.
  • Deployment: integration with your interface, setting up automated build and deployment.
  • Training: a webinar for your team on using and extending the diagram.
  • Support: 30 days of free consultations and bug fixes after deployment.

Development Process and Timeline

Our team implements the Sankey diagram turnkey. Experience with over 50 projects.

  1. Analytics: study your data structure, define key metrics.
  2. Design: develop layout, choose layout algorithm, plan interactions.
  3. Implementation: code the component in React/TypeScript, set up backend data aggregation.
  4. Testing: validate on real data, optimize performance.
  5. Deployment: integrate with your interface, deploy on your server or cloud.
  6. Support: 30 days of free refinements and consultations.

Basic version with tooltip and interactions – 2–3 days (cost starting from $2,000). Extended with drill-down, filtering, and export – 5–7 days (cost starting from $5,000).

Implementation Results

After implementing the Sankey diagram, our clients see conversion increases of 15–30% and CPA reduction of 20–40% by identifying bottlenecks. For example, a client saved $50,000 annually by reallocating ad spend. We provide a 6-month code warranty and full documentation. This interactive chart is a powerful conversion optimization tool. Contact us to order a custom Sankey diagram for your site. Get a consultation from an engineer today.

Setup Web Analytics: GA4, GTM, Yandex.Metrica, and Amplitude

We often see: conversion rate 1.2%, traffic grows, but conversion stays flat. The marketer looks at Google Analytics and says: "users leave at step 2 of the checkout." The developer opens the same step — no errors, Sentry is silent. So it's not a JS bug, but a UX issue or skewed data from analytics. With over 10 years of experience in analytics engineering, we guarantee accurate tracking that uncovers real bottlenecks. Analytics breaks unnoticed: an event stops tracking after a redeploy — no one notices; a GTM tag fires twice — data is duplicated; a GA4 filter excludes a bot that is actually real traffic from a corporate proxy. An audit of your current tags will find the cause within a week.

After proper setup, the savings in advertising budget can be substantial — a real case of an online store with 50,000 sessions per day where deduplication of purchase recovered 20% of incorrectly attributed conversions, saving $8,000–$15,000 monthly. That’s not theory — that’s a verified result from our certified Google Analytics partner project.

Why do GA4 events duplicate and how to fix it?

Universal Analytics is gone, replaced by GA4's event-based model. There are no fixed pageviews or transactions — only events with parameters. This is more flexible but requires proper event design. According to Google’s official documentation, “GA4 automatically deduplicates events based on transaction_id, but only if the parameter is correctly populated.” Many implementations miss this.

Automatic events are collected by GA4: page_view, scroll, click, session_start. Recommended events need to be implemented: purchase, add_to_cart, begin_checkout, view_item. Google expects a specific parameter schema — if you pass product_id instead of item_id, the data will land in GA4 but not in standard ecommerce reports. Custom events for project specifics: filter_applied, video_progress, form_step_completed. Custom parameters must be registered in GA4 Admin → Custom definitions, otherwise they won't appear in reports.

A common mistake is the purchase event being duplicated. Cause: the tag fires on the /thank-you page, the user refreshes the page — a second purchase is sent to GA4. Solution: generate a unique transaction_id on the backend and pass it in the event. In our experience, 80% of e-commerce stores have this issue. GA4 deduplicates based on it (in theory — verify with DebugView). Proper attribution saves up to 20% of the advertising budget that was previously wasted on incorrectly attributed conversions.

How to set up the data layer to avoid data loss?

GTM is a tool for managing tags without code deployment. But "no code" doesn't mean "no architecture." The data layer is the foundation. We pass data from the application to GTM via dataLayer.push(). Structure: event + contextual data. For e-commerce: before opening a product page — push with product data. GTM tag reads from the data layer, not from the DOM.

window.dataLayer = window.dataLayer || [];
dataLayer.push({
  event: 'view_item',
  ecommerce: {
    items: [{
      item_id: 'SKU-12345',
      item_name: 'Product name',
      price: 1990.00,
      currency: 'USD'
    }]
  }
});

Bad practice: GTM tag parses the DOM — looks for the price in span.price, the name in h1. This breaks with any layout change. Good practice: always use the data layer. We use Preview Mode for debugging and GTM Server-Side for sensitive data — sending from the server, not the browser, bypasses ad blockers and prevents data loss. A properly implemented data layer reduces tracking errors by 95%.

How does Yandex.Metrica complement web analytics?

For a Russian audience, Metrica is a must — especially Webvisor. Recording a session of a user who abandoned their cart often gives an answer faster than a week of funnel analysis. Goals in Metrica: event-based (via ym(COUNTER_ID, 'reachGoal', 'GOAL_NAME')) or automatic (button click, page visit). Integration with CRM via Metrica Plus — passing offline conversions. Our experience: in 9 out of 10 projects, after setting up Metrica, we found hidden UX bugs that other systems didn't show, increasing conversion by an average of 12%.

What does product analytics give in Amplitude?

Amplitude is a product tool, unlike marketing-oriented GA4 and Metrica. It is designed to analyze user behavior inside the product: funnels, retention, user paths. Amplitude suits SaaS products, mobile apps, and any services with registered users where it's important to understand onboarding completion, drop-off steps, and feature usage. Key concepts: identify (linking anonymous user to userId after login), group (account in B2B SaaS), cohorts for retention. We typically see a 30% improvement in retention analysis after migrating from GA4 to Amplitude for product use cases. Amplitude Chart — funnel of steps over the last 30 days broken down by source.

Monitoring Data Quality

Analytics without monitoring is a black box. We set up:

  • GA4 Realtime — check after every deploy that key events are coming in
  • Alerting in GA4 — anomaly in the number of purchase events (sharp drop = something broke)
  • GTM Preview in staging before production
  • Manual funnel tests once a week — simply go through the buyer journey and verify everything is tracked
What we check after each deploy
  • All recommended events present in DebugView
  • No duplicates (count purchase per 100 sessions)
  • Data layer structure unchanged after frontend update

What the work includes

Component Description
Audit of existing tags Check current GTM tags, data layer, duplicates, and errors
Event schema design Documentation: event list, parameters, triggers
GA4 + GTM setup Create configuration, tags, custom definitions
Yandex.Metrica Install counter, create goals, set up Webvisor
Amplitude (optional) Set up client and server SDK, cohorts
QA and monitoring Testing in Preview Mode, alerting
Training and handover Access, instructions for adding new events, console

Process and timeline

  1. Audit of existing tags and data (2 days)
  2. Event schema design (2 days)
  3. Data layer development and tag setup (3–5 days)
  4. QA in Preview Mode and staging (2 days)
  5. Deploy and dashboard setup (1 day)
Scenario Timeline
Basic GA4 + GTM setup 1 week
Full e-commerce tracking + Metrica 2–3 weeks
Server-side GTM + Amplitude 3–5 weeks

Cost is calculated individually. Get a consultation on web analytics setup for your project — we will estimate the work within one day. Contact us to get started with a free audit of your current tracking.