Can’t add UTM fields
-
Hi – I just installed your plugin and I’m getting the following code displayed in the pop-up when I click on the add UTM button in the form and it won;t let me close the popup:
jQuery(document).ready(function($) { $('.insert-utm-fields').on('click', function(event) { event.preventDefault(); event.stopPropagation(); var formId = 751; var utmFields = [ '[hidden utm_source_cf7 utm_source_cf7-' + formId + ' class:utm_source id:utm_source]', '[hidden utm_medium_cf7 utm_medium_cf7-' + formId + ' class:utm_medium id:utm_medium]', '[hidden utm_term_cf7 utm_term_cf7-' + formId + ' class:utm_term id:utm_term]', '[hidden utm_content_cf7 utm_content_cf7-' + formId + ' class:utm_content id:utm_content]', '[hidden utm_campaign_cf7 utm_campaign_cf7-' + formId + ' class:utm_campaign id:utm_campaign]', '[hidden gclid_cf7 gclid_cf7-' + formId + ' class:gclid id:gclid]' ]; var content = $('#wpcf7-form').val(); var submitPos = content.indexOf('[submit'); if (submitPos === -1) { submitPos = content.length; } // Remove any existing UTM fields utmFields.forEach(function(field) { var fieldName = field.match(/[hidden ([^\s]+)/)[1]; content = content.replace(new RegExp('\[hidden ' + fieldName + '[^\]]*\]', 'g'), ''); }); // Insert new UTM fields just before submit var newContent = content.slice(0, submitPos) + '\n' + utmFields.join('\n') + '\n' + content.slice(submitPos); $('#wpcf7-form').val(newContent); tb_remove(); return false; }); });Can you help?
The page I need help with: [log in to see the link]
The topic ‘Can’t add UTM fields’ is closed to new replies.