Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1183008

    Hi,

    how can i add the conversion tracking code from adwords in the contactform?

    thanks

    #1183189

    Hey webdesignaustria,

    Here are the docs for you:

    Best regards,
    Victoria

    #1207603

    thank you for your answer, but it doesnt works

    #1209434

    Hi,

    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,
    Ismael

    #1209445

    Hi,

    i want to add the Conversion tracking from Google Adwords thats the code:

    #1211537

    Hi,
    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,
    Mike

    #1226651

    Hi,

    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&gt;
    <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

    #1227658

    Hi,

    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

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.