Skip to main content

FFI Journey Analyser

Purpose: AI-powered journey analytics for FE Fund Info (FFI). Looks up users by email or GA4 ID, cross-references HubSpot contacts, matches Salesforce leads to GA4 journeys, and generates Gemini summaries of behaviour and conversion paths.

Where it runs: Google Cloud Run (europe-west1, project ffijourney) behind Cloudflare Access at ffijourney.pacing.agency. A Cloudflare Worker proxies the custom domain to the *.run.app URL.

Last verified: July 2026


Quick Reference​

FeatureCapability
Journey analyserEmail or GA4 _c_ffi lookup with AI 5-section journey summary
Leads intelligenceSalesforce leads enriched with GA4 match status, filters, and export
Audience builderIdentified GA4 users with saved filter sets and snapshot cache
Global data chatGemini Flash/Pro with aggregate BigQuery tools
API + MCP17 REST endpoints at /api/v1, 12 MCP tools
ReportsSix auto-discovered BigQuery analytics reports
Data health15 parallel metric jobs per /health/data refresh

Overview​

FFI Journey Analyser is a client-specific deployment forked from Pacing-Agency/user-journey-analyzer. It replaces Supabase auth with Cloudflare Access and adds HubSpot mirror queries, Salesforce lead matching, and a full leads intelligence workspace.

Key capabilities:

  • Dual lookup — email (HubSpot cross-reference + multi-method GA4 matching) or direct GA4 user_id / user_pseudo_id
  • HubSpot → GA4 matching — gclid, msclkid, li_fat_id, conversion-time window, and SF-date window
  • Leads table — Salesforce CRM leads with inline rematch, CSV import, and HubSpot change badges
  • Journey cache — merge-based enrichment pipeline with BigQuery cache (ffijourney.journey_cache)
  • API keys — self-service rotation at /profile; scope-gated /api/v1 for automation and MCP

A reference re-implementation of FFI also exists in the AQL Journey monorepo (clients/ffi/) but the live FFI tool remains this separate codebase and deployment.


Account Access​

  • Production URL: ffijourney.pacing.agency
  • Authentication: Cloudflare Access (FFI staff Google accounts via Zero Trust policy)
  • API docs: Swagger UI at /api/v1/docs
  • MCP setup: /mcp-setup (Cursor, Claude Desktop, Zed)
  • Account type: CLIENT_ACCESS, INTERNAL

Technology Stack​

LayerTechnology
BackendPython Flask + FastAPI (/api/v1/ via DispatcherMiddleware)
AIGemini 2.5 Flash / 2.5 Pro via google-genai (Vertex, europe-west1)
GA4 dataBigQuery ga4-streaming-data.analytics_297687303
HubSpot dataBigQuery ga4-streaming-data.hubspotdata1.ingest1
Salesforce leadsBigQuery ga4-streaming-data.leads1
Auth (web)Cloudflare Access JWT
Auth (API)X-API-Key (SHA-256 hashed keys in ffijourney.ffi_app.api_keys)
MCPmcp_server.py (12 stdio tools)
DeploymentGoogle Cloud Run + Cloudflare Worker proxy

Repository​


Data Architecture​

DatasetGCP projectPurpose
analytics_297687303ga4-streaming-dataGA4 events (hostname filter: www.fefundinfo.com required)
hubspotdata1ga4-streaming-dataHubSpot contact mirror
leads1ga4-streaming-dataSalesforce leads, matching, chat sessions, HubSpot snapshots
journey_cacheffijourneyEnriched per-user journey cache
audience_cacheffijourneyAudience Builder snapshots
ffi_appffijourneyAPI keys, admin allow-list, import log

Primary GA4 identifier: user_id in _c_ffi format (99%+ coverage post-April 2026 GTM publish). Use user_pseudo_id for historical data before April 2026.


Local Development​

git clone https://github.com/Pacing-Agency/ffi-journey-analyser.git
cd ffi-journey-analyser

python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt

gcloud auth application-default login
gcloud config set project ffijourney

cp run_local.example.py run_local.py # set CF_DEV_EMAIL; CF_DEV_MODE=true
python3 run_local.py

Runs at http://localhost:8080. Local dev bypasses Cloudflare JWT when CF_DEV_MODE=true.


Deployment​

Push to main triggers the Deploy to Cloud Run workflow (deploy.yml):

  1. Authenticates to GCP as ffi-deploy-github@ffijourney.iam.gserviceaccount.com
  2. Deploys via gcloud run deploy --source .
  3. Purges Cloudflare edge cache for ffijourney.pacing.agency

Manual deploy: ./deploy.sh


CI / CD​

WorkflowTriggerPurpose
deploy.ymlPush to mainCloud Run build, deploy, CF cache purge
hubspot_sync.ymlDaily 07:00 UTCHubSpot delta → BQ upsert → lead cascade
warm-cache.ymlDaily + weeklyAudience snapshot and journey cache warm-up

  • User Journey Tool — base platform this tool was forked from
  • AQL Journey — ecommerce sibling on the shared CORE engine (separate live deployment)
  • Google Analytics — GA4 property and BigQuery export
  • Google Cloud — ffijourney and ga4-streaming-data projects
  • Cloudflare — Access policy and Worker proxy for ffijourney.pacing.agency
  • n8n — workflow automation (can call /api/v1 with scoped API keys)

Last Updated: July 2026
Owner: Ben Power
Status: Active (production)