Resources

Free Tool

Google Analytics: Event Tracking Code Generator

Generate event tracking code for Google Analytics in seconds. Compatible with both Asynchronous (ga.js) and Universal Analytics (analytics.js).

What Is Google Analytics Event Tracking?

Do you need a Google Analytics event tracking code generator to track events on your site and get important insights for your digital marketing strategy? Then the onClick JavaScript by Google Analytics is what you need. Follow the steps above, and in a few seconds, the event tracking generator will give you the code you need to track user interactions on your website.

Implementing the Tracking Code on Your Website

The event tracking code generator creates tracking code to track clicks on your website for SEO and analytics purposes.

To implement the event tracking code, you need to add the tracking code to the HTML element people are supposed to click to complete the action.

For example, let's say you want to track the number of clicks on a link on your homepage that points to the pricing page. The HTML for that link might look something like this:

A basic HTML link before adding event tracking code

Once you add the Google Analytics tracking code to that link, it might look something like this:

HTML link with Google Analytics event tracking code added

Configuring Your Events as Goals in Google Analytics

  1. Log into your Google Analytics and click Admin in the sidebar.
  2. Select the correct Google Analytics Account, Property, and View. Then, click Goals under the "View" column.
Google Analytics Admin panel showing the Goals option under the View column
  1. Click New Goal.
Google Analytics New Goal button
  1. Select a custom goal and name your Goal. Use something short and intuitive — it should be obvious for you or anyone what it is about since this name will appear on your reports.
Naming a custom Goal in Google Analytics
  1. Select your preferred Goal ID and Goal Set slot (if you don't have any Goals yet, leave the default option). Select Event, and click Continue.
Selecting Event as the Goal type in Google Analytics
  1. Enter the same values for the "Category", "Action", and "Label" that you added in the tool above, and make sure all dropdowns are set to Equal to. Leave "Value" blank.
Goal details form with Category, Action, and Label fields
  1. Click Save and you should see the Goal you just created. Make sure the "Recording" toggle is set to On.
Goal recording toggle set to On in Google Analytics

Testing Your Google Analytics Goals

  1. Install the Google Tag Assistant Chrome extension on your Google Chrome browser. This tag assistant helps verify Google tags like Google Analytics and Google Tag Manager (GTM) on your web page.
  2. Open your website using Chrome, click on the Google Tag Assistant icon, and click Record.
Google Tag Assistant extension showing the Record button
  1. Click on the element that's supposed to trigger your goal.
  2. Click on the Google Tag Assistant Chrome extension again and click Stop Recording, then click Show Full Report.
Google Tag Assistant Show Full Report button
  1. Select Google Analytics Report.
Selecting Google Analytics Report in Tag Assistant
  1. Select the view that you want to test and click OK.
Selecting the Google Analytics view to test
  1. Scroll down until you find the Conversions section. You should be able to see the name of your Goal, your Conversion Value, and a green tick after it.
Conversions section showing the Goal with a green checkmark

That's it! You've correctly set up your click event as a Google Analytics goal.

Additional Resources

If you found this tool useful, check out these resources to level up your digital marketing: