Do not use blank “campaignId” strings with Google Analytics tags

Sparkline were set with a curious challenge when one of our clients raised a problem with the Google Analytics Source/Medium report. The top Source/Medium by sessions was “(not set) / (not set)”. This was very, very unusual. We asked what could possibly cause GA to not recognise Source/Mediums correctly?

After some untangling, we discovered that the blank string had been set as the campaignId in the GA tags. Since GA couldn’t interpret the blank string, it simply saved the Source/Medium as “(not set) / (not set)”.

Read more »

How to accurately track clicks from aggregator sites

Challenge

GoBear is an insurance policy and credit card research aggregator service. It is critical for GoBear to track the number of clicks directed to its partners’ websites. On the other hand, it is equally important for the partner (e.g. an insurance company or a credit card provider) to measure the number of inbound clicks from GoBear.

Gobear Search Results

 

When a user clicks on the “Go To Provider” button, GoBear tracks this as a “click out” on its end using event tracking. However, the partner also needs to keep track of the click that it receives using an equivalent metric.

“How can the partner track the inbound clicks from GoBear?”

The partner cannot rely on the number of sessions referred from GoBear because this will not be an equivalent comparison to GoBear’s clicks. If the user clicks multiple times within a short period of time, it will be seen as one session on the partner’s Google Analytics reports, but recognised as several clicks in GoBear’s reports. Also, not all clicks would be successfully directed to the partner site if users close their browser before the partner site loads.

Sparkline Solution

For tracking inbound traffic, the partner site can use a Custom Metric to track the number of inbound referrals from GoBear.

  1. Create a Custom Metric called “Lead Count” in Google Analytics (GA).
  2. Create a Constant variable to hold the GA index assigned to “Lead Count”.
  3. Create a Custom JavaScript variable called “CJS Lead Count” in Google Tag Manager (GTM). Depending on the Referrer variable, this will be set to 1 or 0.
  4. Set the “CJS Lead Count” in the GA Pageview tag along with its corresponding index.

Step 1:

Create a custom metric in Google Analytics following the steps in Google Help.

Step 2:

Create a Constant variable and set its value to the index of the Lead Count custom metric assigned in Google Analytics. Here, the index is assumed to be 2.

gobear_step2

Step 3.1:

In GTM, configure the “Referrer” built-in variable.

gobear_step3.1

For example, let us count the inbound traffic from “www.gobear.com/sg. The value of “Referrer” will contain “www.gobear.com”.

Step 3.2:

Create a Custom JavaScript variable with the condition to check if the referrer is the aggregator site (in our example, it is gobear.com) and set the counter value to 1 or 0 accordingly.

gobear_step 3.2

Code:


function() {
return {{Referrer}}.indexOf("gobear.com") > -1 ? 1 : 0;
}

Step 4:

Set this Custom JavaScript variable in the GA Pageview tag (reference: Google Help).

gobear_step4

Result:

As a result of this, the partner-site will be able to track the number of inbound referrals from its aggregator sites. For example:

gobear_result

This will allow them to better compare click out metrics reported by GoBear instead of trying to reconcile session numbers.

Track Internal Campaigns to Google Analytics using Google Tag Manager

Footprints

If you use Google Analytics (GA) in your website, then you’re probably already tracking your external campaigns properly. But are you tracking your internal campaigns as well? These are marketing campaigns that you run within your website, like homepage banners that link to promoted products.

External campaigns are tracked with GA’s built-in utm_source, utm_medium, utm_campaign, utm_content and utm_term parameters to identify the marketing campaigns that drive users to your website.

However, for internal campaigns, you shouldn’t use these utm_source / utm_medium / etc tracking. If you do, GA replaces your external campaign tracking with these internal ones.

There are four ways to track internal campaigns in GA:

MethodProsCons
Enhanced Ecommerce’s PromotionsDesigned for internal campaign reporting, built into GAReport is limited to Ecommerce’s metrics
EventsQuick to setup and understandLimited to clicks on links, doesn’t encapsulate entire user behaviour
Site SearchNo coding neededFunction isn’t meant for internal campaigns
Custom DimensionsDesigned for business-specific reporting needs, flexible usageSome coding required

I personally prefer the Custom Dimensions method because it makes the most sense. It doesn’t force Events nor Site Search to be adapted for campaign tracking. And it can be used in reports that contain other dimensions and metrics.

And it can be done fairly easily with Google Tag Manager (GTM). Let me show you how.

Read more »