Membership 2 thank you page pixel

Hi there,

I'm trying to place a conversion/confirmation pixel onto the thank you page of a Membership 2 Pro thank you page - but I can't see anything clear on how to add this in.

I have a page template that the majority of the website uses, and I was looking for some kind of function to check if the current page is a thank you page, e.g.
<?php
if( is_thank_you_page( $membership_id ) ){
echo $tracking_pixel;
}
?>

is there anything available for this plugin?

or is there an alternative way I can place a conversion pixel into a specific thank you page (to make sure the pixel doesn't fire on other pages or memberships)?

Thanks

  • Jude
    • DEV MAN

    Howdy @jamie48

    Hope you are keeping well !

    Here is a snippet that helps you get the page type from the plugin.

    $thanks = MS_Model_Pages::get_page_url( 'MS_PAGE_REG_COMPLETE' ) ;
    if ( get_permalink() == $thanks )
     echo $tracking_pixel;

    I also suggest you take a look the events object to incorporate your code. It was made for something like this.

    do_action( 'ms_model_event', $event, $data );
    do_action( 'ms_model_event_' . $type, $event, $data );

    Variables like the ones below give you all details you need.

    $event->user_id
    $event->membership_id
    $event->name

    This can be used as long as nothing but a http request needs to be sent out for a pixel.

    Let me know if you need further clarifications and I'll be happy to help

    Cheers
    Jude

  • Jamie Luke
    • Flash Drive

    Hi there Jude,

    Thank you for that, however when I use that simple if statement, it crashes the page/returns a blank page.

    Is there a typo in that code?

    I even tried to just echo "test" to see if it was because of the pixel

    if ( get_permalink() = $thanks ){
    			echo "test";
    }

    and that still broke it.

  • Michael Bissett
    • Recruit

    Hey Jamie Luke, apologies for the delay on this one!

    In your code, change this:

    $thanks = MS_Model_Pages::get_page_url( 'MS_PAGE_REG_COMPLETE' ) ;

    To this:

    $thanks = MS_Model_Pages::get_page_url( MS_Model_Pages::MS_PAGE_REG_COMPLETE, false ) ;

    That should do the trick here, I'm seeing that it does on my site. :slight_smile:

    Kind Regards,
    Michael

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.