See llms.txt for all machine-readable content.

Back to Templates

Send weekly AI assistant traffic reports with GA4, Gmail and Google Sheets

Quick overview

This workflow runs every Monday and pulls AI-assistant referral traffic from Google Analytics 4, compares it to the previous week, then emails an HTML summary via Gmail and appends weekly totals to a Google Sheets log.

How it works

  1. Runs every Monday at 8:00 on a schedule.
  2. Loads configuration values, including the report recipient email and a regex list of AI assistant sources to track.
  3. Queries Google Analytics 4 for the last 7 days of sessions, users, key events, and engaged sessions where the session source matches the AI source regex.
  4. Queries Google Analytics 4 for the previous 7-day period with the same AI source filter to enable week-over-week comparison.
  5. Retrieves total sessions for the last 7 days from Google Analytics 4 to calculate AI traffic share of all sessions.
  6. Aggregates results by AI assistant (for example ChatGPT, Perplexity, Gemini, Copilot, and Claude), calculates changes, builds an HTML report, then sends it via Gmail and logs the weekly metrics to Google Sheets.

Setup

  1. Create and connect a Google Analytics 4 credential, then select your GA4 property in all three Google Analytics nodes.
  2. Create and connect a Gmail credential that can send email, and set the recipient address in the workflow settings.
  3. Create a Google Sheet with columns for week_ending, ai_sessions, ai_sessions_previous, change_pct, share_of_all_sessions_pct, ai_key_events, and top_assistant, then add a Google Sheets credential and select the spreadsheet and sheet name used for logging.
  4. Update the AI source regex in the settings if you want to add or remove tracked assistants/domains.