Browsing Category

Google Analytics

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).

Google Analytics

Why Direct Traffic Is High In Google Analytics

I was hesitant to write a new post about this topic as it is already covered well, in this post I will try to focus more on the diagnoses and recommendations than explaining the reasons behind direct traffic.

What is direct traffic in Google Analytics:

The popular conception about direct traffic that it is a type-in traffic where people type in the website directly in the browser or visit it using a browser bookmark list, but realty is that it is not always the case, all web tracking software need the referring URL to identify the traffic source, and it comes empty too them they recognize it as a direct traffic.

Take this URL as an example https://www.google.com/search?q=seo when Google Analytics detects a URL like that, it compares to its existing list of known sources, they will see that Google.com is listed as a search engine, the q=seo will confirm that it is a search URL not one of Google's properties, the other checking point is to check if the landing page has GCLID in the URL which refers to paid search, GA also checks for any UTM variables that forces GA to override the source. If there is no GCLID or UTMs then GA will categories this medium as organic and the source will be Google.

As you can see the referring URL is vital for GA to track any traffic, when the referring URL is missing r the source of the visit will be categorized as direct.

What causes the referring URL to be missing (in other words what causes direct traffic in GA):

The most popular reasons for direct traffic in GA are:

  • Excluded referrals in Google Analytics without a proper cross domain tracking
  • Type-in traffic (When someone types a website’s URL into their browser, it’s direct traffic) and browser's bookmarks
  • Traffic via desktop e-mail clients like Outlook
  • Traffic from APPs and desktop software
  • Fake direct traffic from spam bots
  • Referral traffic from a secure (HTTPS) site to a non-secure (HTTP) site
  • Non-web documents like PDF or DOC
  • Traffic from incorrectly tagged campaigns (mainly wrong UTM tracking)
  • Traffic from links that do not send referral traffic (links with rel="noreferrer" tag)
  • Traffic from browsers that block referrals using add-ons or due to firewall settings

I do not want to spend a lot of time explaining what causes direct traffic in GA, especially that many of the reasons above are beyond webmasters control, direct traffic will be always available in GA, it is normal to see 10%-20% direct traffic, no point of fighting, all what webmasters need to do is inspecting the problem and making sure that they have done everything from their end too prevent it.

Diagnosing direct traffic in GA:

Most traffic sources in GA have another tracking point, first thing is to check if GA traffic is matching the numbers provided by other platforms:

  • Install Google Search Console and make sure that the organic traffic in a specif time frame matches the number of sessions in Google Analytics for the same time frame
  • If you are running Google Ads make sure the number of clicks in Google Ads' dashboard matches the sessions in GA
  • Same thing applies to Facebook ads or any other platforms

If the numbers are close that will be a good signal that the most important traffic sources are tracked properly, in the next step I will explain:

How to reduce direct traffic in Google Analytics:

You do not need to worry about every reason for direct traffic, especially the ones you can not control, like type-in traffic, no-referrer etc, direct traffic will be always there, just work on things that are under your control:

  • Make sure GA settings are correct and the code is installed on every single page of the website
  • Check the referral exclusion section in GA and make sure all excluded domains have cross domain tracking installed.
  • Make sure all pages are served with HTTPS with no errors, broken HTTPS can stop browsers from passing referral path and showing traffic as direct
  • Tag email campaigns and other marketing channels (especially APPs advertisement) using UTM
  • Filter out bot traffic in GA if there is any

Finally just remember, it is almost impossible to reduce direct traffic to zero, 10%-20% is normal, just do your part and keep monitoring and diagnosing any spikes in direct traffic.

Google Analytics

Google Analytics Page Filters Explained

I was checking which page filters in Google Analytics can be used to track user journey on the website, so I can use those filters in conversion rate optimization, I did the two sessions below and tracked the results in Google Analtyics:

First session (flat URL structure):

/landingpage
/visitedpage1
/visitedpage2
/visitedpage3
/visitedpage4
/visitedpage5

Second session (deep URL structure):

/landingpagefodler/
/landingpagefodler/pagelevel1
/landingpagefodler/pagelevel1-2
/landingpagefodler/pagelevel1-3
/landingpagefodler/pagelevel1-4

/landingpagefodler/pagelevel1/pagelevel2/
/landingpagefodler/pagelevel1/pagelevel2-1
/landingpagefodler/pagelevel1/pagelevel2-2
/landingpagefodler/pagelevel1/pagelevel2-3

/landingpagefodler/pagelevel1/pagelevel2/pagelevel3
/landingpagefodler/pagelevel1/pagelevel2/pagelevel3-1
/landingpagefodler/pagelevel1/pagelevel2/pagelevel3-2
/landingpagefodler/pagelevel1/pagelevel2/pagelevel3-3

I will check the results of each filter and mark it as useful or useless to study the user journey and do conversion rate optimization:

Landing page (useful): will show the first page visited in a new session :

Destination page (useless): all pages visited in a session will be destination pages:

Exit page (useful): last page visited in the session:

Next page path (useless): it seems to be just telling the potential path for the next page on the same folder level:

Second page (useless): not sure what is that, it seems to be including the second page up in the hierarchy of the site:

Previous page path (very useful): this is showing the previous page that the user visited before getting to the current page:

Page depth (useful): it is an indicator to the number of pages visited by a user (even in multiple sessions):

Page path level 1 (useless): this filter seems to be analyzing the folder levels and deciding the page path based on that:

Page path level 2 (useless): similar to level one, but it shows the second level in the folder structure:

Page path level 3 (useless): similar to level one and 2:

Search destination page (useful): a page that is clicked on after a user conducted an internal search:

Start page (useless): a page where a user started an internal search:

Google Analytics

Track Form Abandonment Using Google Analytics Funnel Visualization

My previous post was about CRO, in that post I included form optimization as an important step for a better CRO. Form optimization can not be done without collecting data about users interaction with the form, and form abandonment is probably the most important metric that can do that.

What is form abandonment:

Form abandonment is the event where people start filling a form (at least filling one field) but did not click the submit button, so they have the intent to fill the form but due to possibly some hurdles the did not complete it, possible hurdles:

  • Long form (too many fields)
  • Technical issues (the form is not working on some devices or browsers)
  • The form has personal questions that users are not willing to fill
  • The form is broken or the Captcha is so difficult.

There are some online service like Hotjar that can track form abandonment, but unfortunately Hotjar does not work with every form easily, not mention that the data lives outside Google Analytics which means you have another platform to work on and monitor. You can see the form tracking chart offered by Hotjar below, it gives you the time spent by users field each field and the abandonment rate for each field.

In this post I will provide a step by step tutorial how to do form abandonment tracking using Google analytics. I will assume you a simple form on your website like the one belwo:

The source code of the form will like like this:

I will assume that the submission will lead to a thank you page like www.yourwebsite.com/thank-you, please be aware that this tutorial will require a good knowledge of Google Analytics and Google Tag Manager (GTM).

The method I will be explaining will be utilizing the funnel visualisation feature in Google Analytics, which is not designed initially for that, it is designed more to track multiple pages funnel. Considering that a high level of accuracy is not required here the method below should provide a good insight on where and why people abandoning your form.

Step #1:

First step will be pushing an event to the data layer when a user try to fill in a field along with the field name, you can do that by adding the JavaScript code below as a custom HTML tag to your Google Tag Manger:

(function($) {
$(document).ready(function() {
$('form :input').blur(function () {
if($(this).val().length > 0 && !($(this).hasClass('completed'))) {
switch($(this).attr('name')) {
case "first_name":
virtualp = "first-name";
break;
case "last_name":
virtualp = "last-name";
break;
case "phone_number":
virtualp = "phone";
break;
case "email_address":
virtualp = "email";
break;
case "comments":
virtualp = "comments";
break;
default:
virtualp = "unknown";
}

dataLayer.push({'eventCategory': 'Form - ' + $(this).closest('form').attr('name'),
'eventAction': 'completed',
'feildLabel': virtualp,
'event': 'gaEvent'});
$(this).addClass('completed');
}
else if(!($(this).hasClass('completed')) && !($(this).hasClass('skipped'))) {
$(this).addClass('skipped');
}
});
});
})(jQuery);

Please note that:

  • The code above assume that jQuery is installed already on the website.
  • You need to change the case to match your field names.
  • You can change virtualp (which is going to be the virtual page URL) to anything also just make sure the page is not already existing on your website.

Step #2:

Add a datalayer variable to track the field name:

datalayer-variable

Step #3:

Create a virtual page view to track every form field filling as a pageview:

Google-analytics-virtual-pageview

The firing rule for the tag above will be as below:

After that publish your GTM container.

Step #4:

In Google analytics create a goal that tracks the thank your page with funnel steps that reflect the virtual page names you have set in step #1:

GA-goal

When you have enough data you should be able to see a funnel visualisation as below:

The funnel above should tell which field is causing that highest abandonment rate so you can either remove or change it.

Step #5 - Bonus - Track scrolling down as a page view:

Some forms are placed below the fold, or they are multiple step forms where people need to scroll down to see the other parts of the form. For those forms you can add the scrolling down to the form location as a virtual page view (see the tag and the trigger below and use them in GTM):

scroll-depth-tag

Summary:

Form tracking abandonment is an important part of conversion rate optimization, always do it with any tool you feel comfortable with, there are other things you can do from a CRO prospective when it comes to form:

  • Exit intent pop-up window trying to give users unrefusable offer to stay on the page and fill the form.
  • Tracking filled fields even if people did not click submit and use it to better understand user behaviour.