How to add automated events?

Image of Iron Brands

Published on Nov 23, 2023 and edited on Feb 27, 2024 by Iron Brands

In this guide, we'll explain how to add the automated event script to your website for the more extensive data collection on events like outbound links, email clicks, and file downloads.

This script complements the standard embed script that you've already installed on your site.

Let's dive in!

  1. Add automated events
  2. How the automated events script works
  3. Automated events in practice
  4. Final Thoughts
Logo of MichelinMichelin chose Simple AnalyticsJoin them

Add automated events

The automated event script collects customizable events, allowing you to track specific actions you're interested in. By default, it captures outbound links (links pointing to a different website), email address clicks, and file downloads (such as PDF, Excel, and other file formats).

To install the automated event script, add the following code to your website adjacent to the standard embed script:

<script async src="https://scripts.simpleanalyticscdn.com/auto-events.js"></script>

If you're using a custom domain, replace script.simpleanalyticscdn.com with your custom domain name.

You can customize the script's settings if needed, such as specifying events to collect or file extensions to track for downloads. The following code demonstrates an example of the script with available options:

<script async src="https://scripts.simpleanalyticscdn.com/latest.js"></script>
<script
  async
  src="https://scripts.simpleanalyticscdn.com/auto-events.js"
  data-collect="outbound,emails,downloads"
  data-extensions="pdf,csv,doc,xlsx,zip,docx,xls"
></script>

How the automated events script works

In the automated event script, you'll notice various data parameters, such as data-collect and data-extensions. With data-collect, you can specify the events you want to track, such as outbound links, emails, and downloads. These events should be listed in a comma-separated format.

If you would like to exclude an event type, simply remove it from the list. For example, to track only outbound links and downloads, set data-collect to "outbound, downloads".

Similarly, the "data-extensions" parameter is relevant for tracking file downloads. By default, it collects events for downloading file types such as PDF, CSV, DOC, XLSX, ZIP, DOC, and XLS. If you wish to track additional file extensions, simply add them to the list. If you don't specify any extensions, the script will use the default list as mentioned.

Two additional options are available in the automated event script: "use title" and "data full URLs."

The "use title" option allows you to track the title of a link instead of its URL. This title is not the webpage title displayed in the browser but the tooltip that appears when you hover over a link. For most users, this option isn't necessary and can be ignored.

The "data full URLs" option, when set to "false" (default), collects only the hostname of the destination website instead of the entire URL. If you prefer to capture full URLs, you can set this option to "true."

Automated events in practice

Let's check out an example. We recently wrote a blog about the fact that Finland declared Google Analytics in violation of GDPR.

events-blog-post.png

In the blow, we have a link going to a press release, which is an external link.

Now when you install the “automated events” script, you should see some data for this link after a while, of course, people need to click on outbound links, emails, or downloads before the first event happens.

We already installed the script on our website and can show the data in our dashboard.

events-dashboard.png

The "Events" tab in Simple Analytics acts like an event explorer, allowing you to view collected events for your website. If you're interested in outbound events, you can type "outbound_" to filter and display only those events. Event names consist of text, numbers, and underscores.

When you find an outbound link event, you can add a "path" column to see the unique pages where the link is present. This helps identify the pages on which the event occurred.

For example, if the link appears on two blog posts, clicking the outbound link and revisiting your dashboard will show the event counter incrementing, reflecting the link click.

events-path.png

Final Thoughts

Adding the automated event script to your website enhances your data collection capabilities by tracking specific actions such as outbound links, email clicks, and file downloads.

With customization options and the ability to track additional file extensions, you can gain valuable insights into user behavior on your site. This information can help you optimize your content and user experience, ultimately driving better overall website performance.

If you have any questions, feel free to shoot us a message

GA4 is complex. Try Simple Analytics

GA4 is like sitting in an airplane cockpit without a pilot license

Start 14-day trial