Created
March 8, 2017 23:25
-
-
Save thomasplevy/19282a4ea7adc75c75272189f2c37425 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // don't add this line to a functions.php file! | |
/** | |
* A sample function which will output conversion pixels on successful LifterLMS Checkouts | |
*/ | |
function my_lifterlms_tracking_pixel_scripts() { | |
// only proceed if an order has been completed | |
if ( ! isset( $_GET['order-complete'] ) ) { | |
return; | |
} | |
$key = $_GET['order-complete']; | |
$order = llms_get_order_by_key( $key ); | |
if ( $order && is_a( $order, 'LLMS_Order' ) ) { | |
// you can access various pieces of order information via the order | |
// see https://github.com/gocodebox/lifterlms/blob/master/includes/models/model.llms.order.php | |
// for a full list of data that can be accessed via the order object | |
// here's a few useful examples | |
$id = $order->get( 'id' ); | |
$price = $order->get( 'total' ); | |
$fname = $order->get( 'billing_first_name' ); | |
$lname = $order->get( 'billing_last_name' ); | |
?> | |
<!-- replace this comment with the pixel / tracking code snippet --> | |
<?php | |
} | |
} | |
// if the pixel needs to be output in the html HEAD | |
add_action( 'wp_head', 'my_lifterlms_tracking_pixel_scripts' ); | |
// if the pixel needs to be output before the closing BODY tag | |
add_action( 'wp_footer', 'my_lifterlms_tracking_pixel_scripts' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment