Created
October 29, 2014 18:47
-
-
Save thomasgriffin/62689c45fa4bf7b6cb31 to your computer and use it in GitHub Desktop.
Custom action hook for custom conversion tracking in Canvas in OptinMonster.
This file contains hidden or 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 | |
add_action( 'optin_monster_ajax_action', 'tgm_om_custom_tracker', 10, 2 ); | |
function tgm_om_custom_tracker( $action, $data ) { | |
// If not our action, do nothing. | |
if ( 'track_optinmonster_custom' !== $action ) { | |
return; | |
} | |
// If our ID is not passed, do nothing. | |
if ( empty( $data['id'] ) ) { | |
return; | |
} | |
// Load our interfaces and track the conversion. | |
if ( ! class_exists( 'Optin_Monster_Track_Datastore' ) ) { | |
require plugin_dir_path( Optin_Monster::get_instance()->file ) . 'includes/global/track-datastore.php'; | |
} | |
$track = new Optin_Monster_Track_Datastore( absint( $data['id'] ) ); | |
$track->save( 'conversion' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment