How to Send Event to Google Analytics

Cody Schneider

Sending event data to Google Analytics tells you what users are actually doing on your website beyond just visiting pages. While pageviews are useful, events track meaningful interactions like button clicks, form submissions, and video plays. This article will show you exactly how to send custom events to Google Analytics 4 using the most common methods, Google Tag Manager and direct code implementation.

What is an Event in Google Analytics 4?

In Google Analytics 4, almost every interaction is considered an event. This is a big shift from the old Universal Analytics, which was based on sessions and pageviews with a rigid "category, action, label" structure for events. The GA4 model is far more flexible, using a simpler structure made up of an event name and optional parameters that provide more context.

There are four main types of events in GA4:

  • Automatically Collected Events: These are captured by default when you install the GA4 tracking code. They include basics like page_view, session_start, and scroll (for users who scroll at least 90% of the page).

  • Enhanced Measurement Events: You can enable these with a simple toggle in your GA4 Admin settings. They track common interactions like outbound clicks (click with an outbound parameter), site search (view_search_results), and file downloads (file_download) with no code required.

  • Recommended Events: Google provides a list of suggested event names for common scenarios across different industries (e.g., add_to_cart for e-commerce or generate_lead for lead generation). Using these names helps Google understand your data better and provides access to more detailed reporting features.

  • Custom Events: These are the events you define and name yourself. A custom event can be anything you want to track that isn't covered by the other categories, like a specific call-to-action button click (hero_banner_cta_click) or an interaction with a pricing calculator. This is what we will focus on creating.

Method 1: The Best Way to Send Events (Using Google Tag Manager)

For most marketers and business owners, Google Tag Manager (GTM) is the most flexible and scalable way to manage tracking without constantly needing a developer. GTM acts as a middleman between your website and analytics tools, allowing you to deploy tracking tags via a user-friendly interface.

Let's walk through a common example: tracking clicks on a "Request a Demo" button.

Step 1: Identify Your Button and Create a Trigger

A "trigger" in GTM tells a "tag" when to fire. In our case, the trigger will be the click on our demo button.

  1. Log in to your Google Tag Manager container and click "Preview" in the top right corner.

  2. Enter your website URL and click "Connect." A new tab with your website will open, with the GTM Debug pane connected.

  3. On your website, click the "Request a Demo" button you want to track.

  4. Switch back to the GTM Debugger window. In the left-hand summary, you should see a "Click" or "Link Click" event. Click on it.

  5. Select the "Variables" tab. Here, GTM shows all the information it captured about that click. Look for a unique identifier for your button, like Click Text ("Request a Demo"), Click URL (if it’s a link), or Click ID (if your developer assigned a specific ID to the button).

Let's say the button’s Click Text is "Request a Demo." Now we can create a trigger that only fires when that specific text is clicked.

  1. In GTM, go to "Triggers" and click "New."

  2. Name your trigger something descriptive, like "Click - Request a Demo Button."

  3. Click "Trigger Configuration" and choose "All Elements" under the Click section.

  4. Select "Some Clicks."

  5. Set the condition to: Click Text | equals | Request a Demo.

  6. Save the trigger. Now, GTM knows when to act.

Step 2: Create the GA4 Event Tag

A "tag" is the piece of code that does the work. In this case, our tag will send the event data to GA4 when the trigger we just created fires.

  1. In GTM, go to "Tags" and click "New."

  2. Name your tag clearly, like "GA4 Event - Request a Demo Click."

  3. In "Tag Configuration," choose the tag type Google Analytics: GA4 Event.

  4. For "Configuration Tag," select the tag you use for basic GA4 page tracking (it's often named something like "GA4 Config"). This links your event to the correct GA4 property.

  5. In the "Event Name" field, enter a name for your event. Use snake_case (all lowercase with underscores) and be descriptive. We might use request_demo_click.

Optionally, you can add Event Parameters to send more context with your event.

  • Under "Event Parameters," click "Add Row."

  • For the "Parameter Name," you might use button_text.

  • For the "Value," click the LEGO block icon and choose the built-in variable {{Click Text}}. This will dynamically capture the text of whichever button is clicked.

Step 3: Connect the Tag to the Trigger

Now, we just need to tell the tag when to fire.

  1. Below the Tag Configuration, click on "Triggering."

  2. Select the trigger you created in the first step ("Click - Request a Demo Button").

  3. Click "Save."

Step 4: Test and Publish

Always test before publishing your changes!

  1. Click "Preview" in GTM again.

  2. Navigate to your website and click the "Request a Demo" button.

  3. In the GTM Debugger window, you should see your tag ("GA4 Event - Request a Demo Click") appear under the "Tags Fired" section.

  4. Go to your Google Analytics property and navigate to Admin > Data display > DebugView. You should see your request_demo_click event appear here in near real-time. If it's there, your setup is correct!

  5. Once confirmed, go back to GTM, click "Submit," give your version a descriptive name (e.g., "Added Request Demo Event Tracking"), and click "Publish." Your event tracking is now live!

Method 2: Sending Events Directly with Code (gtag.js)

If you don't use Google Tag Manager and the GA4 tracking script is installed directly in your site's code (you'll see a gtag.js script), you can send events using a small javascript snippet. This method is for users who are comfortable editing their website's HTML or JavaScript files.

The basic syntax for a gtag event is:

gtag('event', 'your_event_name', { 'parameter_name_1': 'parameter_value_1', 'parameter_name_2': 'parameter_value_2' }),

Example: Tracking a Button Click with gtag.js

Imagine you have this simple button in your HTML:

<button id="newsletter-signup">Subscribe Now</button>

To track a click on this button, you would add a JavaScript event listener that calls the gtag() function when the button is clicked.

You could add this script block to the bottom of your HTML page:

<script> document.getElementById('newsletter-signup').addEventListener('click', function() { gtag('event', 'newsletter_signup', { 'button_location': 'footer', 'page_path': location.pathname }), }), </script>

Let's break down what this code does:

  • document.getElementById('newsletter-signup'): This selects the button with the ID newsletter-signup.

  • .addEventListener('click', function() { ... }),: This "listens" for a click on that button. When it happens, it runs the code inside the curly braces.

  • gtag('event', 'newsletter_signup', { ... }),: This is the command that sends the event to GA4.

  • We've named the event newsletter_signup and included two custom parameters: button_location and page_path, to add more detail to our tracking.

To test this implementation, use your browser's Developer Tools (right-click and "Inspect," then go to the "Network" tab) filtering for "collect" to see the request being sent to Google Analytics. You can also use the GA4 DebugView as shown in the GTM method.

How to See Your New Events in GA4 Reports

After your event data starts flowing into GA4, you'll want to see it in your reports. There are a few places to look.

1. The Realtime Report

The fastest way to see if your events are firing correctly is the Reports > Realtime report. Look for the "Event count by Event name" card. You should see your event appear here within minutes of it being triggered.

2. The Events Report

After 24-48 hours, your event data will be fully processed and available in standard reports. Go to Reports > Engagement > Events. This report shows a list of all event names collected, their count, total users, and more. You can click on an event name to see more detailed reporting.

3. Registering Custom Dimensions

If you sent custom parameters with your events (like button_location in our gtag example), they won't automatically appear in your reports. You need to tell GA4 about them first by registering them as "Custom Dimensions."

  • Go to Admin > Data display > Custom definitions.

  • Click "Create custom dimensions."

  • Give your dimension a name (e.g., "Button Location").

  • The scope will be "Event."

  • For the "Event parameter," type the exact name of the parameter you're sending (e.g., button_location).

  • Save it.

After about a day, your new "Button Location" dimension will be available to add as a secondary dimension in your reports, allowing you to segment your newsletter_signup events by where the button was clicked.

Final Thoughts

Mastering event tracking is the best way to move beyond surface-level metrics and understand customer behavior in Google Analytics. Using Google Tag Manager provides a user-friendly way to manage your tracking, while the gtag.js method offers more direct control for those comfortable with code. Pick the method that works for your team and start tracking the interactions that truly matter for your business goals.

While setting up better tracking in Google Analytics is the essential first step, the real objective is to easily access and understand this business-critical data. Connecting all your platforms and manually building reports can quickly become a full-time job. With Graphed, you simply connect your Google Analytics account once and can then ask for reports using plain English. We designed it for marketers who need to combine GA4 data with insights from Shopify, Facebook Ads, or a CRM to see the complete picture of what's driving growth — all without spending hours inside a complicated reporting tool.