Blog da Amicatek

How to add onclick event in Elementor

Elementor is the most used page builder in WordPress today. In all, it adds up to more than 10 million active installations, which is a very expressive number. One of the difficulties in Elementor currently is to associate the onclick event in Elementor.


What is the onclick event?

The onclick event is used so that, when the user or visitor clicks on a certain link or button, a Javascript function is triggered.

Many services such as Google and Facebook use and recommend to improve the measurement of metrics in services such as Ads.

How to use the onclick event in Elementor in a Button (for Facebook Pixel, Google Ads or Google Tag Manager)

  1. Go to Button > Advanced > set “CSS ID”

When you click on the button you want to add the onclick event, click on it and go to the “Advanced” tab and fill in the “CSS ID” field for a unique value. Example: “My_Button”

  1. Add an HTML widget

If possible right after the Button widget

document.addEventListener("DOMContentLoaded", function(event) {    
jQuery('#My_Button a').click(function(){
// tracking code here
// for example, Facebook Pixel:      
  1. Paste the code below into the HTML widget

If you encounter any errors in Elementor, check out our Elementor Errors Guide.


Este artigo te ajudou? Faça uma avaliação usando as Estrelas
Fellipe Soares

Fellipe Soares

Bachelor in Information Systems, he has been working with WordPress for more than 10 years in the creation of solutions for companies and professionals.

Leave a Reply

Your email address will not be published.

Related Content:

Receba mais notícias como essa sobre Tutorials através da nossa Newsletter

Notícias sobre Segurança, Marketing, Performance e Negócios sempre relacionadas ao WordPress todas as segundas-feiras, para você começar bem a semana.