import wixData from 'wix-data';
import wixLocation from 'wix-location';
$w.onReady(function () {
// Get the URL parameter "utm_source" directly using Wix Location API
const utmSource = wixLocation.query.utm_source;
if (utmSource === 'google') {
$w('#multiStepForm1').onSuccess(() => {
let formData = $w('#comp-lpb63umo1').getFormData();
// Assuming formData already has utm parameters
wixData.insert('Leads', {
...formData,
googleAdsLead: true // add custom field indicating a lead from Google
})
.then(() => {
console.log('Lead from Google Ads campaign submitted successfully');
})
.catch((error) => {
console.error('Error submitting lead from Google Ads campaign:', error);
});
});
}
});