Plugin Author
Guido
(@guido07111975)
Hi,
Whole form is executed on the same page. So what you’re trying to achieve will not work, I guess. But I might be wrong of course.. What did you try?
Guido
Hi,
The code I put in on the vscf-form.php file was:
<button type=”submit” name=”vscf_send” id=”vscf_send” class=”btn btn-primary”>’.esc_attr($vscf_atts[‘label_submit’]).’ .onClick=”ga(‘send’, ‘event’, { eventCategory: ‘Contact Us’, eventAction: ‘Send’});”</button>
I’m not really great at PHP, but from what I could see that was the piece of code that generates the button itself, so by putting the onClick code within it would hopefully make it work.
I guess I could try wrapping it around the button in <script> tags if you think that’d work? I’m hesitant to try making too many changes too often as the site is live and the client is using it.
James
Plugin Author
Guido
(@guido07111975)
Hi James,
My javascript knowledge is limited, what’s the purpose of this?
If you want a redirect to a thank you page, please check this reply in another thread. Is this what you want perhaps?
Guido
Hi Guidi,
It’s to track an event goal in Google Analytics. So when people click on the submit button, it sends a ‘signal’ through to Google Analytics so we can see that someone has submitted a form.
I didn’t know you could redirect it to another URL when you submit the form, so that might help, so I’ll look into that as well.
James
Plugin Author
Guido
(@guido07111975)
If you want this, you should change file vscf-form (and for widget file vscf-widget-form).
Open file vscf-form and remove line 232:
return $anchor_begin . '<p class="vscf-info">'.esc_attr($result).'</p>' . $anchor_end;
Add this instead:
$page = home_url('/?page_id=222');
echo '<script type="text/javascript">';
echo 'window.location="'.$page.'";';
echo '</script>';
Create a thank you page and add the page ID in code above (where “222” is).
Now you can use your Google code on that thank you page.
Guido
Excellent, that worked fantastically, thank you! 🙂
Plugin Author
Guido
(@guido07111975)
Great to hear this works for you!
Guido