Installing the ProfitWell in-app snippet with Wordpress and Memberpress

by Tristan Ratchford

  1. Download and install the "My Custom Functions" free plugin
  2. Add the following custom function and replace YOUR_PROFITWELL_TOKEN_HERE with your provided auth token:
function add_profitwell_script_to_footer() {
  global $user_ID;
  if(class_exists('MeprUser') && isset($user_ID) && $user_ID):
    $user = new MeprUser($user_ID);
    ?>
      <script> (function(i,s,o,g,r,a,m){i['ProfitWellObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m); })(window,document,'script','https://dna8twue3dlxq.cloudfront.net/js/profitwell.js','profitwell'); 
                profitwell('auth_token', 'YOUR_PROFITWELL_TOKEN_HERE'); 
                profitwell('user_email', '<?php echo $user->user_email; ?>');</script>
    <?php
  endif;
}
add_action('wp_footer', 'add_profitwell_script_to_footer');


How Did We Do?