• Resolved gracewpuser

    (@gracewpuser)


    Hi,

    I would like to ask if you have a feature that can automatically track the registrations=conversions in Google Analytics.

    Thanks

Viewing 1 replies (of 1 total)
  • Plugin Author Chad Butler

    (@cbutlerjr)

    There’s probably more than one approach to this. However, the way I do it on my site (the WP-Members support site rocketgeek.com runs on WP-Members) is to use the wpmem_register_form_buttons filter to change the register form button HTML to include the ga onClick event handler.

    add_filter( 'wpmem_register_form_buttons', function($string,$tag){
    	if($tag=='new'){
    		$old = '<input id="button" name="submit"';
    		$new = "<input id=\"button\" name=\"submit\" onClick=\"ga('send', 'event', 'button', 'click', 'register');\"";
    		$string = str_replace($old,$new,$string);
    	}
    	return $s;
    },10,2);

    There are several other filters before (when the form is generated) and after (when the success dialog is served) that can be used for adding in ga tracking codes.

Viewing 1 replies (of 1 total)
  • The topic ‘Tracking registrations in Google Analytics’ is closed to new replies.