How to add Conversion Tracking to a button?

Hi,
I need to add a conversion tracking code to a button. The button itself is a „link to URL“ type. I know how to add the code snippet to the project, but how can I call „gtag_report_conversion“ when clicking the button? Attached is the code snippet with the instructions.

Many thanks in advance for support!

Regards,
Michael

Use a custom attribute called onclick

The URL should go between the brackets or leave it blank to grab the current url if I read that right.

Eg.

onclick=“gtag_report_conversion(‘myurl’)”

Thank you for your reply!

I already use the button interaction “Navigate to URL”, so I think in this case it would be enough if the custom attribute looks like that:

onclick=“gtag_report_conversion

right?

I must implement the conversion for a customer of mine and I’ve received the code from his marketing agency, so I don’t have the possibility to check myself, if the tracking is working properly.

Without a URL…
onclick=“gtag_report_conversion()"

Umm, how is it getting the URL then? Its not grabbing the href.

EDIT: I just went and looked at the docs for this, its as I suspected, you need to add the URL. I take it you didn’t read any documentation? It has it all there.

Thank you for your help!

No, I didn’t read any documentation because I didn’t know where to start…Even with the documentation I would have still needed your help with the custom attribute :slight_smile:

Hope you charged a special rate then :grin: