How can I combine event tracking from Google & Bing in onsubmit?

Member

by virginie , in category: Local SEO , a year ago

How can I combine event tracking from Google & Bing in onsubmit?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

3 answers

by cameron_walter , a year ago

@virginie 

To combine event tracking from both Google and Bing in an onsubmit function, you can use the following code as a reference:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
<form onsubmit="return onSubmit()">
    <input type="text" name="name" />
    <input type="submit" value="Submit" />
</form>

<script>
function onSubmit() {
    // Google Analytics tracking code
    ga('send', 'event', 'form', 'submit', 'contact');

    // Bing Ads tracking code
    var universalEventTracking = window.uetq = window.uetq || [];
    universalEventTracking.push({
        'ea': 'form_submit',
        'el': 'contact',
        'ev': 1
    });

    // Return true to submit the form
    return true;
}
</script>


In this example, the onsubmit function calls the onSubmit() function which includes the tracking code for both Google Analytics and Bing Ads.


The Google Analytics tracking code uses the ga() function to send an event with the category "form", the action "submit", and the label "contact".


The Bing Ads tracking code uses the Universal Event Tracking (UET) code to send an event with the event action "form_submit", the event label "contact", and the event value "1".


Finally, the function returns true to submit the form.

by jose_gulgowski , 4 months ago

@virginie 

Please note that in order for the Google Analytics tracking code to work, you need to have the Google Analytics script properly set up on your website. Similarly, for the Bing Ads tracking code to work, you need to have the Universal Event Tracking (UET) code properly set up on your website.


Make sure to replace the placeholders 'form', 'submit', and 'contact' in the code with relevant values for your tracking purposes.


Additionally, it’s important to follow the documentation and guidelines provided by Google Analytics and Bing Ads for implementing event tracking on your website to ensure accurate tracking and compliance with their terms of service.

Member

by susan , 3 months ago

@virginie 

Thank you for the additional clarification. It's important to note that the code provided assumes that you have already set up and configured Google Analytics and Bing Ads properly on your website.


Additionally, make sure to replace the following placeholders with your own values:

  • 'form': Replace with the relevant category for your form.
  • 'submit': Replace with the relevant action or event name for the form submission.
  • 'contact': Replace with the relevant label or identifier for the specific form submission.


To ensure accuracy and compliance, please refer to the documentation and guidelines provided by Google Analytics and Bing Ads for event tracking implementation on your website.


Please also note that the example provided is a general approach and may need to be adjusted based on your specific tracking requirements and implementation setup.