Solved

Add a parameter in the Elementor Buttom code

  • 12 January 2022
  • 7 replies
  • 83 views

Hi there!

 

I have a button added in elementor, and I need to add this code in the div that it’s generated in the code.

 

I have to add this in the button code,

onclick=”plausible(‘sedo-top’)

 

It’s a code that will add an event in Plausible Analytics.

 

 

Needs to be like this:

 

<div class="elementor-button-wrapper">

<a href="LINK" target="_blank" class="elementor-button-link elementor-button elementor-size-xl elementor-animation-grow" role="button" onclick="plausible('sedo-top')">

<span class="elementor-button-content-wrapper">

<span class="elementor-button-icon elementor-align-icon-right">

<i aria-hidden="true" class="fas fa-long-arrow-alt-right"></i> </span>

<span class="elementor-button-text">Ver precio</span></span></a></div>

 

 

Is it possible to do that? If so, how?

 

Thanks

icon

Best answer by Harry Martin 14 January 2022, 07:55

View original

7 replies

Userlevel 3
Badge +3

You can use the dynamic option to link via shortcode.

f.e. using the code snippets plugin.

  1. set the link via dynamic option to shortcode > [customlink]
  2. create the via code snippet shortcode [customlink] :
function customlink() {
$value = use-this-to-create-your-link;
return $value;
}

add_shortcode('customlink', 'customlink');

Maybe no the most elegant way, but should work.

 

Harry

You can use the dynamic option to link via shortcode.

f.e. using the code snippets plugin.

  1. set the link via dynamic option to shortcode > [customlink]
  2. create the via code snippet shortcode [customlink] :
function customlink() {
$value = use-this-to-create-your-link;
return $value;
}

add_shortcode('customlink', 'customlink');

Maybe no the most elegant way, but should work.

 

Harry

 

Hi there Harry! Thanks for the answer.

 

I tried to do this as you told me but seems to not work, I installed the recommended plugin and when I try to save the code in the snippet I get a 500x error.

 

I added it like this,

 

 

What I am doing wrong?

 

As far as I understood, I have to create the snippet and then in elementor as the shortcode as the btn link, is that right?

 

Thanks once again.

Userlevel 3
Badge +3

What I am doing wrong?

 

As far as I understood, I have to create the snippet and then in elementor as the shortcode as the btn link, is that right?

 

Your shortcode is wrong. You have to add the complete link to the $value - variable, not to the add_shortcode function. 

If you not familiar with php you should find another solution for your problem. This way is tricky and full of traps…

 

Harry

 

What I am doing wrong?

 

As far as I understood, I have to create the snippet and then in elementor as the shortcode as the btn link, is that right?

 

Your shortcode is wrong. You have to add the complete link to the $value - variable, not to the add_shortcode function. 

If you not familiar with php you should find another solution for your problem. This way is tricky and full of traps…

 

Harry

 

Hi there once again, Harry.

 

Thanks for the fast asnwer. Yes I noticed that, and it’s working, but I am still not sure how can I add the “plausible” code.

 

I’ve renamed the function to, “sedotop” so I can set multiple trackers.

 

 

If It's possible, how can I add the “plausible(‘sedo-top’)” when the user clicks the btn?

 

Thanks!

Fernando.

 

 

 

Hi there once again.

 

Any ideas in how to add the plausible(‘event-name’)

 

@Harry Martin maybe please 🙏🙏

 

Thanks again and sorry for the trouble.

 

Userlevel 3
Badge +3

Hi,

 

I think I sent you into the wrong direction. You can use the HTML-widget an copy/modify the button-code there. f.e.;

<div class="elementor-button-wrapper">
<a href="https://domain.tld" onclick="plausible('sedo-top')" class="elementor-button-link elementor-button elementor-size-sm" role="button">
<span class="elementor-button-content-wrapper">
<span class="elementor-button-text">Customlink</span>
</span>
</a>
</div>

 

H.

Hi,

 

I think I sent you into the wrong direction. You can use the HTML-widget an copy/modify the button-code there. f.e.;

<div class="elementor-button-wrapper">
<a href="https://domain.tld" onclick="plausible('sedo-top')" class="elementor-button-link elementor-button elementor-size-sm" role="button">
<span class="elementor-button-content-wrapper">
<span class="elementor-button-text">Customlink</span>
</span>
</a>
</div>

 

H.

 

Hi there Harry!

 

Yes, with that way it works, I still need to add some HTML to use some animations but it does work.

 

Thanks a lot :)

Reply