How do I set up an event?
To set up a new event, you can either use gtag.js code on your webpage or Google Tag Manager. If you use gtag.js, add your events anywhere below the Google tag snippet. Google won't process data from events that you place above the Google tag snippet.
For example, the following sample code includes an event called button_click. This code must appear after the Google tag snippet.
<script>
gtag('event', 'button_click', {
'button_name': 'myButtonName',
'screen_name': 'Home'
});
</script>
To send the event when the user clicks the button, you would wrap the above code in some additional JavaScript.
To set up an event using Google Tag Manager, configure a Google Analytics: GA4 Event tag and then create a trigger that specifies when you want to send the event. The following steps show you how to send an event called signup_newsletter when a user clicks a button to sign up for your newsletter.
Start by creating a Google Analytics: GA4 Event tag for the new custom event.
- In Google Tag Manager, click Tags > New.
- Enter a name for the GA4 Event tag at the top (e.g., "GA4 Event - Signup newsletter").
- Select Google Analytics: GA4 Event.
- In Configuration Tag, select your Google Analytics: GA4 Configuration tag.
- In Event Name, enter a name for the event (e.g.
signup_newsletter). This will create a new custom event and the name will appear in your GA4 reports.
Next, create a trigger to send the event when someone clicks the button.
- Click the Triggering box in your GA4 Event tag.
- Click + on the top right.
- Enter a name for the trigger (e.g., "Trigger - Signup newsletter").
You can choose the conditions for sending the event. The following example sends the event based on the button label:
- Click the Trigger Configuration box in your trigger.
- Choose All Elements.
- Click Some Clicks.
-
Set the following trigger condition: "Click Text contains Sign up for the newsletter".
If you don't see Click Text, click the first drop down and then select Choose Built-In Variable. From the menu, select Click Text.
-
Save all your changes.
-
Before you publish your new event in Tag Manager, click Preview to see the data that's recorded when you click the "Sign up for the newsletter" button.
You can use preview mode to test changes to your container before you publish those changes to your website.
How do I create an event?
To create a new event, you can either use gtag.js code on your webpage or Google Tag Manager. If you use gtag.js, add your events anywhere below the Google tag snippet. Google won't process data from events that you place above the Google tag snippet.
For example, the following sample code includes an event called button_click. This code must appear after the Google tag snippet.
<script>
gtag('event', 'button_click', {
'button_name': 'myButtonName',
'screen_name': 'Home'
});
</script>
To send the event when the user clicks the button, you would wrap the above code in some additional JavaScript.
To set up an event using Google Tag Manager, configure a Google Analytics: GA4 Event tag and then create a trigger that specifies when you want to send the event. The following steps show you how to send an event called signup_newsletter when a user clicks a button to sign up for your newsletter.
Start by creating a Google Analytics: GA4 Event tag for the new custom event.
- In Google Tag Manager, click Tags > New.
- Enter a name for the GA4 Event tag at the top (e.g., "GA4 Event - Signup newsletter").
- Select Google Analytics: GA4 Event.
- In Configuration Tag, select your Google Analytics: GA4 Configuration tag.
- In Event Name, enter a name for the event (e.g.
signup_newsletter). This will create a new custom event and the name will appear in your GA4 reports.
Next, create a trigger to send the event when someone clicks the button.
- Click the Triggering box in your GA4 Event tag.
- Click + on the top right.
- Enter a name for the trigger (e.g., "Trigger - Signup newsletter").
You can choose the conditions for sending the event. The following example sends the event based on the button label:
- Click the Trigger Configuration box in your trigger.
- Choose All Elements.
- Click Some Clicks.
-
Set the following trigger condition: "Click Text contains Sign up for the newsletter".
If you don't see Click Text, click the first drop down and then select Choose Built-In Variable. From the menu, select Click Text.
-
Save all your changes.
-
Before you publish your new event in Tag Manager, click Preview to see the data that's recorded when you click the "Sign up for the newsletter" button.
You can use preview mode to test changes to your container before you publish those changes to your website.
How do I track a button click?
To track a button click, add a new event. You can do this with either use gtag.js code on your webpage or Google Tag Manager. If you use gtag.js, add your event anywhere below the Google tag snippet. Google won't process data from events that you place above the Google tag snippet.
For example, the following sample code includes an event called button_click. This code must appear after the Google tag snippet.
<script>
gtag('event', 'button_click', {
'button_name': 'myButtonName',
'screen_name': 'Home'
});
</script>
To send the event when the user clicks the button, you would wrap the above code in some additional JavaScript.
To set up an event using Google Tag Manager, configure a Google Analytics: GA4 Event tag and then create a trigger that specifies when you want to send the event. The following steps show you how to send an event called signup_newsletter when a user clicks a button to sign up for your newsletter.
Start by creating a Google Analytics: GA4 Event tag for the new custom event.
- In Google Tag Manager, click Tags > New.
- Enter a name for the GA4 Event tag at the top (e.g., "GA4 Event - Signup newsletter").
- Select Google Analytics: GA4 Event.
- In Configuration Tag, select your Google Analytics: GA4 Configuration tag.
- In Event Name, enter a name for the event (e.g.
signup_newsletter). This will create a new custom event and the name will appear in your GA4 reports.
Next, create a trigger to send the event when someone clicks the button.
- Click the Triggering box in your GA4 Event tag.
- Click + on the top right.
- Enter a name for the trigger (e.g., "Trigger - Signup newsletter").
You can choose the conditions for sending the event. The following example sends the event based on the button label:
- Click the Trigger Configuration box in your trigger.
- Choose All Elements.
- Click Some Clicks.
-
Set the following trigger condition: "Click Text contains Sign up for the newsletter".
If you don't see Click Text, click the first drop down and then select Choose Built-In Variable. From the menu, select Click Text.
-
Save all your changes.
-
Before you publish your new event in Tag Manager, click Preview to see the data that's recorded when you click the "Sign up for the newsletter" button.
You can use preview mode to test changes to your container before you publish those changes to your website.
How do I add a custom event?
To add a custom event, you can either use gtag.js code on your webpage or Google Tag Manager. If you use gtag.js, add your events anywhere below the Google tag snippet. Google won't process data from events that you place above the Google tag snippet.
For example, the following sample code includes an event called button_click. This code must appear after the Google tag snippet.
<script>
gtag('event', 'button_click', {
'button_name': 'myButtonName',
'screen_name': 'Home'
});
</script>
To send the event when the user clicks the button, you would wrap the above code in some additional JavaScript.
To set up an event using Google Tag Manager, configure a Google Analytics: GA4 Event tag and then create a trigger that specifies when you want to send the event. The following steps show you how to send an event called signup_newsletter when a user clicks a button to sign up for your newsletter.
Start by creating a Google Analytics: GA4 Event tag for the new custom event.
- In Google Tag Manager, click Tags > New.
- Enter a name for the GA4 Event tag at the top (e.g., "GA4 Event - Signup newsletter").
- Select Google Analytics: GA4 Event.
- In Configuration Tag, select your Google Analytics: GA4 Configuration tag.
- In Event Name, enter a name for the event (e.g.
signup_newsletter). This will create a new custom event and the name will appear in your GA4 reports.
Next, create a trigger to send the event when someone clicks the button.
- Click the Triggering box in your GA4 Event tag.
- Click + on the top right.
- Enter a name for the trigger (e.g., "Trigger - Signup newsletter").
You can choose the conditions for sending the event. The following example sends the event based on the button label:
- Click the Trigger Configuration box in your trigger.
- Choose All Elements.
- Click Some Clicks.
-
Set the following trigger condition: "Click Text contains Sign up for the newsletter".
If you don't see Click Text, click the first drop down and then select Choose Built-In Variable. From the menu, select Click Text.
-
Save all your changes.
-
Before you publish your new event in Tag Manager, click Preview to see the data that's recorded when you click the "Sign up for the newsletter" button.
You can use preview mode to test changes to your container before you publish those changes to your website.