How to install the ProfitWell.js Snippet with Google Tag Manager

Updated 7 months ago by Matias Barriento

If your company uses Google Tag Manager you can add our wonderful snippet too.

The first thing you need to know is if you have the current user email available before loading your tags from GTM. That should be above this lines.

<!-- Google Tag Manager (noscript) -->
              <iframe ...>
          <!-- End Google Tag Manager (noscript) -->

If you have the user email before the tag, you could use a JavaScript Variable. If not, you should use a Data Layer Variable.

Using JavaScript Variable

Check if you have any variable inside GTM that references the customer's email, if not create one with the type JavaScript Variable and called pw_user_email

Using Data Layer Variable

Check if you have any data layer variable inside GTM that references the customer's email, if not create one with the type Data Layer Variable and called pw_user_email

Also, for this kind of variable you need a custom trigger. Create one Custom Event called pw_trigger.

PW Tag

Add a New Tag, select Custom HTML and paste this while replacing your token

           (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
           profitwell('auth_token', 'PUBLIC_API_TOKEN_HERE'); // Your unique Profitwell public API token
           profitwell('user_email', '{{pw_user_email}}');

When it asks you for a trigger, select All pages if you are using variables or pw_trigger if you are using a data layer

How to use it

For variables, just make sure you have a global variable with the email called pw_user_email (or the same name you use in the PW Tag)

              pw_user_email = ''

For data layer is more tricky.

Make sure you declared the dataLayer before calling Google Tag Manager

            dataLayer = [];

Whenever you get the user's email, just call

dataLayer.push({'event': 'pw_trigger', 'pw_user_email': user_email})

If you have any questions at all, please reach out to

How Did We Do?