Google Analytics Tracking & Analytics

How to setup a User ID UID property in Google Analytics

Attracting all type of web traffic is becoming more expensive every day (that includes organic, paid and social), maximizing the value of every visit is key for any business to maintain a high profitability (same marketing budget with better ROI will significantly impact the bottom line). Performance marketing is becoming a popular term, as marketers we hear every day about metrics like:

  • Cost per click
  • Cost per lead
  • Cost per acquisition
  • Revenue per channel for ecommerce
  • Revenue per channel for off-line sales

Performance marketing is not possible without enough tracking metrics like the ones above, Google Analytics without any customization is able to provide some of those metrics like CPC and cost per lead but it fails to report on cost per acquisition and revenue per channel for off-line sales. To track those metrics and close the marketing loop we need to communicate data back from the CRM to Google Analytics. Using GCLID, CID and UID + the measurement protocol is the way to accomplish that.

Closing the marketing loop in Google Analytics:

Few years ago I published a post explaining how to communicate back from SalesForce to GA when a sale is close using CID, today I want to explain how to implement a CRM integration using UID, the main advantages of using UID over CID is that:

  • UID can track users through multiple devices while CID can not do that,
  • UID does not expire like CID, it is permanent

On the other hand there is a big problem with UID is that it needs users to be registered with your website (username and password), and use your website while they are logging in to their accounts (works well with shopping carts with recurring customers). In this post I will explain how to close the marketing look in GA using UID setup.

Step 1 - Create a GA UID view:

Create a new GA view with UID enabled (you can keep your old views but you need to start a new one using UID that has no data), in order to do that in your GA account: Click Admin >> navigate to the property in which you want to implement User-ID, in the PROPERTY column, click Tracking Info >> User-ID. Read more here how to complete the process.

Step 2 - Push UID value as a datalayer variable

In my example I will assume that you are using Google Tag Manger, once a user successfully logs in to their account the two datalayer events below must be pushed in the source code, the code below should be placed right after GTM code:

dataLayer.push({
          event: 'login_verified',
          userId: crm_unique_id,
        })

It is very important to have the userId value as a number that is saved in your CRM so you can use the same value to push data back to Google Analytics using the Measurement Protocol.

The code above must be pushed to every page a user visits after logging in, not only the first page they visits after logging in.

Step 3 - Capture UID in GTM

A new datalayer variable must be created in GTM:

The userId variable needs to be added to Google Analytics Settings variable in GTM as a custom field:

By completing this you should start seeing some data in the UID view you created in GA.

Step 4 - Pushing data from the CRM to GA

When a new sale happens in the CRM, the Measurement Protocol must be used to push the data back from the CRM to GA, we need to build dynamic URL and use POST method to push the data to GA (the URL below will push a sale to GA):

https://ga-dev-tools.appspot.com/hit-builder/?v=1&t=transaction&tid=UA-3552196-21&ti=transaction-id&tr=50.00&cu=CAD&uid=wisuid&ic=sku-1234

Check the table below to understand the values that were used in the example above, use the hit builder to test your calls.

Step 5 - Verify the data flow in GA

Go to audience then user explorer, find a userid that you pushed some data back to using the measurement protocol and make sure you can see the data there (something like below):

FAQ:

What happens to users that do not login, can I see them in the UID view in GA?

No, you will not be able to see those users at all, you will need to use the CID view.

What happens to a session where a user visits few pages without logging in then they login after?

Google Analytics will connect the dots for you and append the previous pages to the session when the user logs in. There could be some delays for that to happen and become visible in GA (possibly 24 hours sometimes).

You Might Also Like

No Comments

    Leave a Reply