How to install the ProfitWell.js Snippet for Retain

Overview

ProfitWell Retain needs you to add bit of JavaScript to your application so that it can display in-app notifications to your users, as well as overlay our payment forms on-top of your marketing site. Installation requires adding the snippet both on your marketing site, as well as inside your web-app (if applicable).

Instructions for platform specific instructions below:

Marketing Site

Retain reduces the friction of needing your users to sign into your app to update their payment information by overlaying the payment forms directly on your marketing site. You can pick any public facing marketing site —see Meetup below.

Copy and paste this snippet of javascript on your site, making it available on as many pages of your site as possible (ideally, all of them). The ProfitWell snippet was designed to work asynchronously to not affect page load speed and to gracefully handle any errors to not affect the normal functioning of the page. 

<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', 'PUBLIC_API_TOKEN_HERE'); // Your unique Profitwell public API token
</script>

In-App

If the user is logged in, make sure you pass the user's email to the snippet. If there are multiple users under one user who is being billed, you can substitute user email with the user id from your data provider (stripe customer 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', 'PUBLIC_API_TOKEN_HERE'); // Your unique Profitwell public API token
profitwell('user_email', 'USER_EMAIL_HERE'); // enter the Customer email of the logged-in user
</script>

* replace profitwell('user_email', 'USER_EMAIL_HERE') with `profitwell('user_id', '$the_stripe_user_id_of_the_account')`


How Did We Do?