Sorry if this was already asked but I couldn’t get it to work. I have set up a telephone number call button on my website and I want to track conversions of each click for adwords purposes. I can’t seem to make it work because the conversion tracker tells me it is not connected. Can someone please tell me what do I have to do on my website designer to add the onclick custom code to the button and link it to the conversion tracker?
In short, follow Step 1 and get your Event Snippet - this will be some JS that you’ll add to your page’s head.
Once you have it, add it to your page’s head like so (substituting the below code with your own custom snippet):
<script>
function gtag_report_conversion(url) {
var callback = function () {
if (typeof(url) != 'undefined') {
window.location = url;
}
};
gtag('event', 'conversion', {
'send_to': 'AW-CONVERSION_ID/CONVERSION_LABEL',
'value': 1.0,
'currency': 'USD',
'event_callback': callback
});
return false;
}
</script>
On Step 2, where it asks you to add an onclick attribute to the button, you could normally do this with custom attributes, but certain attributes are reserved, so here’s a Javascript snippet that will add the onclick attribute to your button on page load.
Then, you should be done and ready to test it. I would read that guide in more detail to ensure you’re testing correctly and that all is set up properly, but this should work. (Though I should note – I haven’t tested this yet.)
Hello, just to inform that I tried this last thing you told me @mattvaru but itd didn’t worked out.
AdWords didnt recognize there vas a button in my page so it didnt link the conversion.
However i embeded a button and styled it and it worked so I think this is a good solution.