Re: How to trigger a conversion goal using javascript ?

Anonymous
Not applicable

How to trigger a conversion goal using javascript ?

HI,

I want to trigger a javascript code when someone fills out a form.

This JS code will trigger a goal for an AB testing website.

I am already using this code but it seems not working :

<script>

MktoForms2.whenReady(function (form){

  1. form.onSubmit(function () {

var vals = form.vals();

  1. window._vis_opt_queue = window._vis_opt_queue || [];
  2. window._vis_opt_queue.push(function () {

_vis_opt_goal_conversion(200);

alert("Submitted values: " + JSON.stringify(vals));

});

});

});

</script>

thanks for your help

3 REPLIES 3
SanfordWhiteman
Level 10 - Community Moderator

Re: How to trigger a conversion goal using javascript ?

Please post a link to the page on which this code is actually running (it has no meaning without seeing the context with this_vid_opt_queue object available).  And be explicit about "not working."

Anonymous
Not applicable

Re: How to trigger a conversion goal using javascript ?

Hi,

For example on landing page :http://pages.videojet.com/PPC-bottle-printer_Landing-Page-AB-VWO.html

Using Visual Website optimizer, you can set up goals. Here, the goal 200 is the for submitted goal. I want Marketo to send via JS the info which triggers the 200 goals on VWO, when a form is filled.

you should be able to see inside the source code :

>
<script>
  MktoForms2.whenReady(function (form){
  //Put your code that uses the form object here.
form.onSubmit(function () {
  window._vis_opt_queue = window._vis_opt_queue || [];
  window._vis_opt_queue.push(function () {
  _vis_opt_goal_conversion(200); //replace 200 with the goal in VWO for forms if different
  });
  });
</script>

By not working, it seems that Marketo does not recognize the trigger when a form is filled.

thanks for your help

SanfordWhiteman
Level 10 - Community Moderator

Re: How to trigger a conversion goal using javascript ?

onSubmit() works fine.  I don't see it on your page, however.

Instead of complicating your testing environment, pare down the code to only the onSubmit handler.