Installing the ProfitWell in-app snippet with Wordpress and Memberpress

Updated 2 weeks ago by Esteban Galiano

  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() {
$token = "{YOUR_PROFITWELL_TOKEN_HERE}";

$current_user = wp_get_current_user();
$user_init = "";
if ($current_user->exists()) {
$user_init = "profitwell('user_email', '{$current_user->user_email}');";
}

echo "
<script type='text/javascript'>
(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', '$token');
$user_init
</script>
";
}
add_action('wp_footer', 'add_profitwell_script_to_footer');


How Did We Do?