• Resolved mra16r

    (@mra16r)


    [context]

    Basically, I’m integrating google tag manager to track order form submission, which I will use to optimize my Google ads.

    Now, I successfully track the form submission, but I want to include a value in the submission, which would be the total of the order.

    This value would come from the calculation field in forminator.

    ——

    I was watching this tutorial that shows how to do it for a order form, but he doesn’t show it for a order form with actual order total value.

    This is the tracking script I am using in tag manager, which I guess decides what data layer to push in Tag manager?

    <script>
    /**
    * Author: Md Hasanuzzamna
    * Linkedin: https://linkedin.com/in/md-h
    * Youtube: https://youtube.com/@leomeasure
    * Email: [email protected]
    */

    (function() {
    function formDataToObject(formData) {
    var object = {};
    formData.forEach(function(value, key) {
    object[key] = value;
    });
    return object;
    }

    jQuery(document).on('forminator:form:submit:success', function (e, formData) {
    var formDataObject = formDataToObject(formData);

    window.dataLayer = window.dataLayer || [];
    dataLayer.push({
    event: 'forminator_form_submit',
    form_id: formDataObject.form_id,
    inputs: formDataObject
    });
    });
    })();
    </script>n?

    Now, I don’t see how I can add the order total in the script, so it’s pushed to Google Tag Manager.

    Thanks

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @mra16r

    I hope you are doing well.

    This happens because the calculation is not part of formData, in that case, you need to hook in before the submit trigger,

    $(document).on( 'before:forminator:form:submit', function( e, formData ){
        forminator_calculation_value = $( 'your-selector' ).val();
    } );

    Then you will have access to “forminator_calculation_value” on forminator:form:submit:success as well.

    Note, that extending the code I’m afraid will be outside the scope of support we can provide. For that, you’ll need to hire a developer to provide the required custom code for you. WordPress provides a jobs directory here https://jobs.wordpress.net/, if you need further advice about it, feel free to email [email protected].

    Subject: ATTN: WPMU DEV support – wp.org

    Best Regards
    Patrick Freitas

    Thread Starter mra16r

    (@mra16r)

    Hi Patrick, thanks for the reply.

    I’m not exactly sure how to implement the code you provided.

    Does it go in the forminator tracking code? Or in another tag?

    For reference, these are my tags
    https://imgur.com/z8Fg3WE

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @mra16r

    Since custom coding is out of the scope of our support, I’m afraid we can’t share the complete code, the code my colleague shared is an example you will need to extend it for your need to make work as expected.

    Does it go in the forminator tracking code? Or in another tag?

    This should be placed in a similar location as the first script, either within the Forminator tracking section, global site scripts, or GTM, depending on your setup and preference.

    The code can be implemented inside a PHP code using the code snippet plugin or by adding it to your theme function.php file, or you can add it directly as Javascript using the Simple Custom CSS and JS plugin.

    Kind Regards
    Amin

    Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi @mra16r

    We haven’t heard from you in a while, I’ll go and mark this thread as resolved. If you have any additional questions or require further help, please let us know!

    Kind Regards,
    Kris

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