-
AuthorPosts
-
February 10, 2020 at 11:52 am #1183008
Hi,
how can i add the conversion tracking code from adwords in the contactform?
thanks
February 10, 2020 at 7:29 pm #1183189April 27, 2020 at 8:37 pm #1207603thank you for your answer, but it doesnt works
May 4, 2020 at 7:25 am #1209434Hi,
Did you create event goals in the GA console?
// https://support.google.com/analytics/answer/1033068#Anatomy
After creating a goal, you have to use the gtag command either as the value of the onclick attribute or the function to trigger on a click event.
// https://developers.google.com/analytics/devguides/collection/gtagjs/events
This is the line that you have to adjust.
$att = "onclick="_gaq.push(['_trackPageview', '/VP/XXX/XXX']);"";
Replace _gaq with gtag.
Best regards,
IsmaelMay 4, 2020 at 8:31 am #1209445Hi,
i want to add the Conversion tracking from Google Adwords thats the code:
May 9, 2020 at 11:33 pm #1211537Hi,
Sorry for the late reply, an easy way to do this is to go to the Google Tag Manager use the trigger configuration to set a click trigger for a custom class in your developer settings tab for your contact form.Or, try adding this code to the end of your functions.php file in Appearance > Editor:
add_filter('avf_contact_form_submit_button_attr','avia_add_submit_attributes_to_cf', 10, 3); function avia_add_submit_attributes_to_cf($att, $formID, $form_params){ $att = "onclick="_gaq.push(['event', 'conversion', { 'send_to': 'AW-671553693/j_4iCNeJscABEJ2xnMAC', 'event_callback': callback }]);""; return $att; } function custom_event(){ ?> <script async src="https://www.googletagmanager.com/gtag/js?id=AW-671553693"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'AW-671553693'); </script> <?php } add_action('wp_head', 'custom_event');
Best regards,
MikeJune 30, 2020 at 8:13 am #1226651Hi,
thanks for answer but it doest work, here is my code:
—–General website tag——–
<!– Global site tag (gtag.js) – Google Ads: 985134556 –>
<script async src=”https://www.googletagmanager.com/gtag/js?id=AW-985134556″></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag(‘js’, new Date());gtag(‘config’, ‘AW-985134556’);
</script>————Event snippet————-
<!– Event snippet for Lead conversion page
In your html page, add the snippet and call gtag_report_conversion when someone clicks on the chosen link or button. –>
<script>
function gtag_report_conversion(url) {
var callback = function () {
if (typeof(url) != ‘undefined’) {
window.location = url;
}
};
gtag(‘event’, ‘conversion’, {
‘send_to’: ‘AW-985134556/r6bWCL_D8cIBENzr39UD’,
‘event_callback’: callback
});
return false;
}
</script>many thanks
July 3, 2020 at 6:33 am #1227658Hi,
Thank you for the update.
You forgot to add the avf_contact_form_submit_button_attr filter as @Mike suggested above. It should add the onclick attribute to the submit button and trigger the gtag function once the contact form is submitted. You can also create a script that listens or waits for a click event from the submit button, then triggers the tag manager function.
// https://www.w3schools.com/jsref/met_document_addeventlistener.asp
// https://api.jquery.com/on/Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.