2 actions for onsubmit not working


I am trying to manually track a goal through a form using onsubmit to first validate the form and then track the goal.

onSubmit=“return valForm(this) && piwikTracker.trackGoal(1);”

This is working in IE and Chrome but not firefox or safari.

In safari and firefox normal tracking is working for the site and the validation is working but it won’t call the piwikTracker.trackGoal(1). If I put the tracker in front of the validation the tracker calls but the validation doesn’t and submits without checking.

Any help pls

(vipsoft) #2

Use a wrapper function

function validateAndTrack(e)
    var rc = valForm(e);

    if (rc) {

    return rc;


onSubmit="return validateAndTrack(this)"


Still the same, calls the goal for ie and chrome but not firefox and safari. set up as

Arrival date



Finally figured out after looking at a past post with a similar problem of a onsubmit or onclick call not working. The post call was opening in the current page, changing this to opening in a new page allowed the call to work with the original onSubmit=“return valForm(this) && piwikTracker.trackGoal(1);” or using a wrapper function. Not sure if this is a piwik issue or a firefox/safari issue.

But sorted

(Matthieu Aubry) #5

bkiwi99 this is interesting – Would you be able to submit a short FAQ to explain to other users how to do it? I think it would be nice to have this in piwik Faq. I will add it. Please write it here or email matt@piwik.org - thanks!