Google analytics - trackPageview script in multi-page form

I don't think that it is clear exactly what you are asking....

"submit" is a one time action for the entire form, not just one page... depending on what your needs are (which again is not clear - at least not to me)... you could do something like javascript window.location (which can be used like a redirect), or something like js sessionStorage to keep copies of values stored locally (this only works in newer browser versions that support html5). If you do a web search on those you can find more info. I have linked them to a couple of pages to help get you started.
 
If what you are trying to do is fire off a call to _gaq_push() whenever the user moves from one page to another, you'd need to add an event handler for the 'fabrik.form.change.page.end' event.

So create a ./components/com_fabrik/js/form_X.js file (where X is the numeric ID of your form. Fabrik will automagically include that JS on your form page. In that file, you'll need to do something like ...

Code:
window.addEvent('fabrik.loaded', function () {
    Fabrik.addEvent('fabrik.form.change.page.end', function (form) {
        // insert your code here, current page num should be in form.currentPage, probably like this ...
        _gaq.push (['_ trackPageview', '/your_form_sef_link?start_page' + form.currentPage']);
    });
});

Note that the start_page=X is an actual query string arg, so if you append that to the URL for a Fabrik multi-page form, the page should load with the form on the specified page (with page numbering starting from 0).

I can't recall offhand if the outer event, the window.addEvent() is still necessary, which is waiting for the main Fabrik JS init to finish, and the main Fabrik object to become available for use. I seem to recall we now delay requiring the form_X.js files until that's done, but I may be wrong. So it's possible that this code may never run, as fabrik.loaded may have already been fired prior to the form_X.js getting loaded.

If that happens, remove that outer event, and just do the Fabrik.addEvent(), which triggers whenever the user changes pages in a multi-page form. The page.end event triggers once the page changing is done (so after validation etc). There is also a page.start event, which triggers as soon as they hit the button, but the page may not actually ever change (if it fails vaidation).

NOTE - I don't usually go in to this much detail on Community posts (this is more of a "Standard" subscription level response), but I'm kind of helping genyded get a handle on how Fabrik does things.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Staff online

Members online

Back
Top