@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.