Skip to content

Instantly share code, notes, and snippets.

@thomasgriffin
Created October 29, 2014 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thomasgriffin/62689c45fa4bf7b6cb31 to your computer and use it in GitHub Desktop.
Save thomasgriffin/62689c45fa4bf7b6cb31 to your computer and use it in GitHub Desktop.
Custom action hook for custom conversion tracking in Canvas in OptinMonster.
<?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