WebinarGoing global the right way: Unlock international SaaS growth - Feb 7th   Join us
How to install the Profitwell snippet using Google Tag Manager with one container


Overview

For this installation path, we expect you to have only one Google Tag Manager container for both your Marketing site and Web-app site. In this case, we recommend you install the snippet once but start with a different behavior based on which site the snippet is in.

  • Marketing sites: users can't sign in to these sites, e.g. landing pages, marketing sites, promotional pages.
  • Web-Apps: users can sign into them, although they may also be able to visit these sites anonymously, without an account.
If your marketing site and web-app site are in different containers, you should check these instructions.

It is recommended to first load the snippet and then, once your app knows exactly whether there is a logged-in customer or not, start it.

Load the snippet

  1. Click on New Tag and write a meaningful name, like ProfitWell Snippet Load.
  2. On Tag Configuration, click on Custom HTML.
  3. Paste the ProfitWell snippet, replacing PUBLIC_API_TOKEN_HERE with your public API token.
    <script id="profitwell-js" data-pw-auth="PUBLIC_API_TOKEN_HERE">
        /* DO NOT DELETE - this code is used to accept our payments or send data to ProfitWell*/
        (function(i,s,o,g,r,a,m){i[o]=i[o]||function(){(i[o].q=i[o].q||[]).push(arguments)};
        a=s.createElement(g);m=s.getElementsByTagName(g)[0];a.async=1;a.src=r+'?auth='+
        s.getElementById(o+'-js').getAttribute('data-pw-auth');m.parentNode.insertBefore(a,m);
        })(window,document,'profitwell','script','https://public.profitwell.com/js/profitwell.js');
    </script>
  4. Check Support document.write below the HTML snippet.
  5. On Triggering, select All Pages.
  6. Save the tag.

Start it

From within your page, you have to tell Google Tag Manager's Data Layer whether there is a logged-in customer or not, in other words, if you are in your Marketing site or your Web-app site.

  1. If there is a logged-in customer (In-app site):
    dataLayer.push({ 'event': 'start_pw','pw_user_email': user_email})
  2. If you are sure that the customer is anonymous (Marketing site):
    dataLayer.push({ 'event': 'start_pw' })
    For more information on the Data Layer, visit the Google Tag Manager Developer Guide.

Then, on the corresponding Google Tag Manager container, ensure that the pw_user_email variable is defined:

  1. Go to Variables and under User-Defined Variables, click on New and write pw_user_email as the name
  2. On Variable Configuration, select Data Layer Variable
  3. Write pw_user_email as the Data Layer Variable Name and click on Save

After that, add the PW Start tag and publish:

  1. Click on New Tag and write a meaningful name, like ProfitWell Snippet Start
  2. On Tag Configuration, click on Custom HTML
  3. Paste this snippet to start:
    <script>
        profitwell('start', { 
            'user_email': {{pw_user_email}}
        });  
    </script>
    Do not worry about anonymous customers, the above snippet will work for them, and also for those that are logged in.
  4. On Triggering, click on + (New Trigger) and write a meaningful name, like Start PW
  5. On Trigger Configuration, click on Custom Event
  6. In Event name, write start_pw (or whatever event name you pushed to the Data Layer.)
  7. Save the trigger, Save the tag and Submit all the changes


Need more help?

Login to your Paddle account to chat directly with our Seller Support Team or…