Track link clicks
trackLink()
is the function used to track clicks on links on your website. A small duration of timeout is kept so the event logs can be generated or the page would change before the method is called. The function is something like this with link and properties as attributes.
Brevo.trackLink(
link, /*mandatory*/
properties /*optional*/
);
The attributes are mentioned below in a table.
Attribute | Datatype | Description | Value |
---|---|---|---|
link | DOM element | It is the DOM element that you want to track | document.getElementById('download_casestudy_a'); |
properties | JSON object | It is a JSON object where you can pass properties that describe click context or the visitors state | page title, last name, first name etc. |
Implement
trackLink
after the tag
trackLink()
needs you to pass the DOM elements which should have been loaded before. Therefore it's better to implementtrackLink()
after the<body>
tag while making sure that your DOM elements are already loaded.
Example:
An example is given below where you want to track if visitors downloaded a pdf file. If link is the DOM element you want to track clicks on, then your code would look like:
var link = document.getElementById('download_casestudy_a');
var properties = {
'casestudy': 'A'
}
Brevo.trackLink(link, properties);
Updated 2 months ago