Overview
For this installation path, we expect you to have two different Google Tag Manager containers: one for your marketing site, and another one for your web-app site.
- 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 you only have one container, you should check these instructions.Below, the instructions for every container:
Marketing Site
- Open the corresponding GTM container, click on New Tag and write a meaningful name, like
ProfitWell Snippet.
- On Tag Configuration, click on Custom HTML.
- Paste the Marketing Site 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'); profitwell('start', {}); </script>
- Check Support document.write below the HTML snippet.
- On Triggering, select All Pages.
- Save the tag and Submit the changes.
Web-App
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. Start by going to your Web-app container.
Load the snippet
- Click on New Tag and write a meaningful name, like
ProfitWell Snippet Load.
- On Tag Configuration, click on Custom HTML.
- Paste the Web-App Load 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>
- Check Support document.write below the HTML snippet.
- On Triggering, select All Pages.
- Save the tag.
Start the snippet
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.
- If there is a logged-in customer:
dataLayer.push({ 'event': 'start_pw', 'pw_user_email': user_email })
- If you are sure that the customer is anonymous:
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 (Web-app), ensure that the pw_user_email
variable is defined:
- Go to Variables and under User-Defined Variables, click on New and write
pw_user_email
as the name. - On Variable Configuration, select Data Layer Variable.
- Write
pw_user_email
as the Data Layer Variable Name and click on Save.
After that, add the PW Start tag and publish:
- Click on New Tag and write a meaningful name, like
ProfitWell Snippet Start.
- On Tag Configuration, click on Custom HTML.
- Paste the Web-App Start Snippet.
<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. - On Triggering, click on + (New Trigger) and write a meaningful name, like
Start PW.
- On Trigger Configuration, click on Custom Event.
- In Event name, write
start_pw
(or whatever event name you pushed to the Data Layer). - Save the trigger, Save the tag and Submit all the changes.