How to Start Sending GA4 Data via Discord Webhook?

Photo by appshunter.io on Unsplash
Quick Answer: Yes, you can send GA4 metrics to a Discord channel for free by combining Discord Webhooks with Google Apps Script (GAS). No bot is required. Simply create a Webhook URL, use GAS to fetch yesterday's sessions from the Analytics Data API, and POST the data to Discord to achieve automated daily notifications.
However, building a full SEO report that includes Search Console (GSC) data requires significantly more effort. For overall strategy and advice on choosing the right KPIs, refer to the pillar article: Google Analytics Discord Integration (SEO Monitoring).
Can You Send Google Analytics (GA4) Data with Just a Discord Webhook?
In short, yes. However, a Webhook is essentially a "delivery point" for messages to Discord; it doesn't have the capability to fetch data from GA4 on its own. The actual setup involves using GAS or your own server to retrieve numbers from GA4 and then POSTing those results to the Webhook.
While you could build a Discord Bot, Webhooks are much lighter if you only need one-way periodic reports like SEO monitoring. They eliminate the need for managing bot tokens or maintaining Gateway connections, allowing everything to be contained within a single script.
For those starting for free, GAS + Webhook is a logical first step. On the other hand, you will need to handle authentication and keep up with API specification changes yourself. Whether to use a managed product or build it yourself should be decided based on the long-term maintenance costs.
What Should You Prepare Before Starting?
At a minimum, you need the following four items: a Discord server and channel to receive the reports, a Webhook URL linked to them, a Google account with edit permissions for a GA4 property, the Analytics Data API enabled in Google Cloud, and finally, a Google Apps Script project to host your code.
You can find your GA4 Property ID in Google Analytics.

If this is your first time using the API, you'll need to create a project in GCP, enable the Data API, and configure OAuth or a service account so GAS can access it. For personal blogs, having the executing Google account's GA4 view permissions is often sufficient.

Initially, keep your metrics simple—perhaps just "Yesterday's Sessions" and the "Week-over-Week" comparison. As you add more metrics, the script and the message format become complex, making it harder to maintain. If you want to include GSC impressions or CTR, you'll need a separate API and query, so it's best to treat that as a second-phase expansion.
How Do You Create a Discord Webhook?
Open your Server Settings, go to Integrations and click "Create Webhook":

And add a Webhook. Choose the destination channel and give the Webhook a clear name like "GA4 Daily" so you can identify it later. Copy the URL provided and save it in a safe place, such as GAS Script Properties, rather than hard-coding it directly into your script.

A Webhook URL should be treated like a password. Do not push it to GitHub or include it in screenshots. If it ever leaks, regenerate the Webhook in Discord to invalidate the old URL. For team use, it's safest to pass it through a password manager or GAS "Script Properties."
You can test the posting by running a fetch-like operation from the GAS editor or using curl to POST a JSON payload. Testing in a private channel first will save you the stress of accidental misposts. Once the post is successful, you can move on to embedding GA4 numbers into the message body.
Steps to Fetch GA4 Data and Send it to Discord via GAS
Create a new project in GAS, enable the Analytics Data API service.

And putting the code:
function sendGA4SessionsToDiscord() {
// GA4 Property ID
const propertyId = '123456789';
// Discord Webhook URL
const webhookUrl = 'https://discord.com/api/webhooks/xxxxx/yyyyy';
// Get yesterday's sessions
const request = {
dateRanges: [
{
startDate: 'yesterday',
endDate: 'yesterday',
},
],
metrics: [
{
name: 'sessions',
},
],
};
const response = AnalyticsData.Properties.runReport(
request,
'properties/' + propertyId
);
const sessions =
response.rows?.[0]?.metricValues?.[0]?.value || '0';
// A message sending to Discord
const message = {
content: `📊 Yesterday Sessions: ${sessions}`,
};
const options = {
method: 'post',
contentType: 'application/json',
payload: JSON.stringify(message),
};
UrlFetchApp.fetch(webhookUrl, options);
Logger.log(`Sent sessions count: ${sessions}`);
}
Finally, execute the code after updating the Property ID and Wehbook URL.

When sending to Discord, construct a JSON payload according to the Webhook specifications. Using the content field for plain text is the simplest method. While embeds look more professional, be mindful of character limits. Use UrlFetchApp to POST the data and log the response code (usually 204 for success) to make future troubleshooting easier.
As a sample, start with a single line: "📊 Yesterday Sessions: xxx". Once this works, the core of your Google Analytics Discord integration is complete. Adding Search Console data or rankings for multiple pages is simply a matter of adding more queries on top of this framework.
How to Write Readable Reports for Discord
Daily messages should be short, include comparisons, and help you visualize the next action. If you only list numbers, you'll eventually feel the need to open the full dashboard anyway. Limiting the report to three lines—such as "Organic Sessions," "Day-over-Day," and "Same Day Last Week"—is ideal for anomaly detection.
A structure with the date in the title line followed by metrics in the body is easiest to read. If you manage multiple sites, prefix the message with the domain name or dedicate separate channels for each. Keep emojis to a minimum, such as simple arrows for increases or decreases, to maintain a professional look.
If you want to expand this for SEO monitoring, you might add a weekly update for "one query with rising impressions." Long daily notifications often lead to "skipping" the read. For organizing metric priorities, refer to the Google Analytics Discord integration for SEO monitoring guide.
How to Set Up the Automated Daily Trigger
In the left menu of GAS, select "Triggers" and choose "Time-driven." Since the timezone depends on the script's execution account, set it to your preferred morning time. Starting with "Once per day, around 8:00 AM" is usually sufficient, as you can always adjust the frequency later.

Ensure the script runs without errors manually before enabling the trigger. When the authorization screen appears, grant permission to read Analytics data and connect to external URLs. To avoid silent failures, consider wrapping your code in a try-catch block that emails you or posts a "Fetch Failed" message to Discord if something goes wrong.
The free tier of GAS is usually enough for personal use, but pay attention to execution time if you have many sites or heavy reports. Since running multiple properties in one script can lead to timeouts, it's better to split them into separate scripts or limit the metrics fetched.
What to Do When It Doesn't Work (No-Code Alternatives)
First, check for Webhook URL errors, deleted channels, incorrect GA4 Property IDs, disabled APIs, or missing OAuth scopes. Discord often returns 403 or 404 errors, while GA4 errors will appear in the execution logs. Avoid rewriting the entire script without checking the logs, as that often introduces new issues.
As your reporting needs grow to include Search Console data, visual graphs, or multi-user permission management, the maintenance cost of a custom script rises sharply. At that stage, it's worth considering a solution like GA4 Report Stream to deliver GA4 and GSC data to Discord automatically. Think of it not as a competitor to the free Webhook route, but as an option to "buy back your time."
The full picture of SEO monitoring, which KPIs to track, and operational strategies are summarized in our hub article: Google Analytics Discord Integration for SEO Monitoring. Building your Webhook foundation here and expanding with pillar articles or dedicated products is the most efficient way to proceed.
Would you like to send Google Analytics data to Discord automatically?
With GA4 Report Stream, you don't need to create a program in GAS to retrieve your Google Analytics data and send it to your Discord. Simply connect Google Analytics and Discord to GA4 Report Stream, and your Google Analytics metrics will be sent to Discord immediately. Give it a try!
Get Started with GA4 Report Stream