onclick
to the ahref
tag, like so:
</body>
element).
about-us-link
to the ID you’ve used in your code and also change about click
to an Event name of your choosing. That Event name will then show up on your dashboard when someone clicks the “About us” link.
If you instead want to fire off an event based on a CLASS (instead of an ID), you’d use the following code. CLASSES are useful as they can be used infinite times on a single page, whereas IDs should only be used once per page (per HTML spec). In this example, we have a series of files that a user can download and we want to see how often these are downloaded.
.download-link
is the class used by your link(s) in your code, and file download
is an Event name that’ll then show up on your dashboard when it’s fired off.
In addition to this, you can also get fancy and have dynamic names for your file downloads. Let’s do another example:
data-filename="File X"
, for example, to the links and then use getAttribute('data-filename')
instead of grabbing the href.