adding date from form to event for google tag manager

Home Forums Quform WordPress adding date from form to event for google tag manager

This topic is: resolved
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #37315
    deranaloge
    Participant

    hi there,
    i have found your code here:
    jQuery(function ($) {
    $(‘.quform-form-1’).on(‘quform:successStart’, function () { dataLayer.push({‘event’: ‘Contact Form’});
    });
    });

    how can i add data from the form to the gtm? i need to send some information i get in the form to gtm.

    thanks for your help

    #37320
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #37323
    deranaloge
    Participant

    hi,
    thanks for your answer. now it does work when submitting the form.
    but i need to send two form fields also so i have more information about the content.

    so waht i need is to add some kind of this into it:

    jQuery(function ($) {
    $(‘.quform-form-1’).on(‘quform:successStart’, function ()
    { dataLayer.push({
    ‘event’: ‘Contact Form’
    ‘produkt_id’: ‘form_field22’,
    ‘produkt_name’: ‘form_field11’
    });
    });
    });

    so my problem is how can i get the data that the user filled in the field to push it to gtm (see produkt_id and produkt_name)? form_field22 and form_field11.

    i hope i was able to desscribe it. so i just need to know how to push the form field data 🙂

    #37325
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #37327
    deranaloge
    Participant

    hi,
    thank you for your answer. i now added this code and it seems to work:

    
    jQuery(function ($) {
        $('.quform-form-1').on('quform:successStart', function () {        
            var produkt = $('.quform-field-1_20').val();
            
            dataLayer.push({
                'event': 'formsuccess',
                'produkt': produkt
            });
        });
    });
    

    thank you again

    • This reply was modified 3 months, 2 weeks ago by deranaloge.
    #37526
    deranaloge
    Participant

    hi, one more question,
    can i add this piece of code for each form in the custom java script settings page?
    (i know i have to change the fomr id and the form field)

    thanks again

    #37529
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy