Execute Javascript when the registration form is completed I am running Facebook advertising campaign for my site. The below code needs to be executed when registration is completed. 
How can I achieve this?

&lt;script&gt;
// Track when a registration form is completed (ex. complete subscription, sign up for a service)
fbq('track', 'CompleteRegistration');
&lt;/script&gt;
You need to add callback for the form submission. Something like this

function your_module_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if ($form['#form_id'] == 'your_form_id') {
    $form['#submit'][] = 'custom_callback';
  }
}

function custom_callback() {
  drupal_set_message('This is my custom message');
}


Now, after the form submission, the custom_callback will also be executed.

If the code is Javascript and the form submission is via Ajax, you may have a look at the Ajax framework and Ajax framework commands topics in the API documentation. How to execute custom javascript code after an ajax succes (using the Drupal Ajax framework) ? is another useful page/