I’m trying to track conversions on a button that is triggered by AJAX with visualwebsiteoptimizer’s Custom Conversion Goal Code which is generated javascript code.
If I put it in php file that is being triggered by AJAX would it run this javascript code aswell sending details back to the visualwebsiteoptimizer?
Or is there a better way of doing this? (ie onclick event on the submit button…)
You are not going to be able to run javascript from inside your PHP script. Javascript needs to be executed by the browser (at least in this case).
Your best bet is to run the custom conversion code in an onclick (or similar) event. You may want to look into using a $(‘form’).submit() event or the callback function for your ajax request.