Dimension Widening: Import data directly into Google Analytics

There are lots of different ways to put data in Google Analytics. You can collect data from a website with JavaScript. You can collect data from an app using an SDK (Android or iOS). Or you can collect data from any network connected device using the measurement protocol. But there’s another way to add data […]

Dimension Widening: Import data directly into Google Analytics is a post from: Analytics Talk by Justin Cutroni

The post Dimension Widening: Import data directly into Google Analytics appeared first on Analytics Talk.

There are lots of different ways to put data in Google Analytics. You can collect data from a website with JavaScript. You can collect data from an app using an SDK (Android or iOS). Or you can collect data from any network connected device using the measurement protocol.

But there’s another way to add data to Google Analytics – you can import data using a feature called Dimension Widening.

You can add data to Google Analytics a number of ways - including Dimension Widening.

You can add data to Google Analytics a number of ways – including Dimension Widening.

With Dimension widening you can import additional dimensions and metrics directly into Google Analytics via a CSV upload or programmatically import data via an API.

Let’s take a look at how you might use Dimension Widening to augment the data in your account, and ultimately do better analysis.

Why Add More Data?

Analytics is more valuable when you can align the tool more closely with your business strategies and tactics. Adding additional data, like customer history, content publishing information, advertising cost data, etc. can help provide context to your data, thus making it easier to gauge performance and identify opportunities for improvements.

Adding additional data can also streamline your reporting (yes, basic reporting still happens) by consolidating all of your data in a single system that everyone has access to.

That’s where Dimension Widening comes in.

It is a mechanism to move data into Google Analytics.

How Dimension Widening works

You can upload two types of data to Google Analytics: Dimensions and Metrics.

A dimension is an attribute of a user or the sessions she creates.

A metric counts something – like time, money, clicks, etc.

When you use Dimension Widening you are uploading values for one or more dimensions or metrics.

You can upload values for existing dimensions/metrics or you can upload values for new dimensions/metrics that do not exist in Google Analytics.

When Google Analytics process the data it will join your custom data to the the existing data using something called a key.

The key binds your data, the data uploaded in a CSV file or sent programatically, to the Google Analytics data. When Google processes the custom data it will look at the value for the key, and then try to find the same value in the Google Analytics data.

If Google Analytics finds a matching keys then it will take the data in that row of the custom data and pull it into Google Analytics.

The key links your custom data to the data in Google Analytics.

The key links your custom data to the data in Google Analytics.

There are four basic steps to configuring Dimensioning Widening.

1. Identifying the data you want to import.

Step one is really simple, identify the data that you want to add to Google Analytics.

Remember, you can import a value for any dimension or metric that currently exists in Google Analytics. OR you can import values for custom dimensions and custom metrics that are not normally found in GA – more on this below.

When choosing the data you want to import ask yourself this – what data to I need to understand the behavior of my users? How can I make my analytics life easier by consolidating data in Google Analytics?

You also need to define your key. This is obviously critical. If you can’t define a key then you can’t import data.

2. Create the schema in Google Analytics.

Once you define your key and the dimensions/metrics you want to import it’s time to add the schema to Google Analytics. Think of this step as telling Google Analytics how to interpret the CSV file (or data feed) that you will import.

Choose a property in the admin section, then choose Data import and Dimension Widening.

The Dimension Widening settings are in the Data Import section of a property.

The Dimension Widening settings are in the Data Import section of a property.

To begin you need to name the data set you will import. You can actually upload multiple data sets (more on this later), so make sure you name it something very descriptive, like “Campaign Data” or “Content Information”.

Then choose the view where you would like the data applied.

Every data set must have a name, and you must specify which views to apply the data to.

Every data set must have a name, and you must specify which views to apply the data to.

TIP: Dimension widening will permanently change the data in a reporting view! It’s a good idea to test your dimension widening on a TEST view before applying it to your main reporting view.

Now add the schema. First, add the key that you’ve defined for your data.

Next, specify the dimensions and metrics that you want to add.

You must enter a schema into Google Analytics. Add the key along with the dimensions you would like to widen.

You must enter a schema into Google Analytics. Add the key along with the dimensions you would like to widen.

Here’s something cool – as you choose your key and dimensions Google Analytics will automatically show you the column headings that you will need to add to your CSV file.

As you add your schema Google Analytics will provide the column headers for your CSV file.

As you add your schema Google Analytics will provide the column headers for your CSV file.

Notice that they’re not the names that appear in the drop down boxes. They’re the dimension/metric names that are used in the API. Fear not – you don’t need to understand what they mean.

3. Build your CSV file.

Once you finish defining your schema choose save.

You’ll be presented with two options: get more details of your CSV file OR get an API key to upload your data programatically. Let’s focus on the Get Schema option.

Once you define your dimension widening schema you can download a CSV template or get an API key.

Once you define your dimension widening schema you can download a CSV template or get an API key.

Click the Get Schema button.

This window contains some really useful information. First, a list of the column headers that you need to add to your CSV file. This includes your key and all the other dimensions that you are adding to Google Analytics.

There’s also a way to download a CSV template for your specific data. The template is just an Excel file with the headers added to the first row.

Google Analytics will provide the column headers for your CSV and provide a CSV template that you can fill with your data.

Google Analytics will provide the column headers for your CSV and provide a CSV template that you can fill with your data.

4. Upload your CSV file or Send Data via API

Remember, there are two ways to add your data – via an API or manually via a file upload process. Let’s focus on the later – the file upload.

This isn’t too complicated, just click upload :) Once the file is uploaded Google Analytics will widen your data as it is processed.

You can check on the processing of your data using the Refresh button.

You can check on the processing of your data using the Refresh button.

NOTE: when you use Dimension Widening the data you import is NOT applied to historical data. Your data is only applied going forward.

I find that GA can process the file very fast (minutes). You may want to refresh your list often to determine if the new data has been added.

That’s it! That’s the basic process.

But you probably want to use Dimension Widening to import custom data, not data that’s already in Google Analytics. Let’s take a look at how to do that.

How to add Custom Data

You can also add custom dimensions and custom metrics to Google Analytics via dimension widening. The process is almost exactly the same. The only difference is that you must first define your custom dimensions or metrics in the Google Analytics admin section.

To upload a dimension or metric that does not exist in Google Analytics you must first define those custom dimensions or metrics.

To upload a dimension or metric that does not exist in Google Analytics you must first define those custom dimensions or metrics.

There’s not a lot of configuration here. Just give your dimension a name and choose a scope.

NOTE: You can only widen between dimensions and metrics of same scope. For example, you can’t widen from user scope Key to Hit scope dimensions. Check out this (somewhat old) article on Custom Variables to learn more about scope.

That’s it. Now you can choose these custom dimensions (or metrics) when you add your schema for Dimension Widening.

Once you define a custom piece of data it will be available in the Custom Data schema interface.

Once you define a custom piece of data it will be available in the Custom Data schema interface.

Then create your CSV file with the correct headers and upload your data.

Note: Custom Dimension and metrics are only available in Google Analytics customizations – this includes custom reports, custom segments and dashboards. They can also be used in certain analysis tools, like secondary dimensions.

An Example: Uploading simple publisher data

Let’s say I’m a publisher. I want to add the publication year, author for each article. My key to join my data with GA data is the URL of each page. I already defined two custom dimensions, one for page publication year and one for page author.

I’m going to define my data schema in Google Analytics.

Defining a custom data in your dimensions widening schema.

Defining a custom data in your dimensions widening schema.

Now I build my CSV file using the correct headers for my key and dimensions that I would like to widen.

A sample CSV file with custom dimensions.

A sample CSV file with custom dimensions.

Next I upload my file…

And finally, I have data in my custom dimensions. Here I can see the data in a Custom Report.

Custom Dimensions can be used in a Custom Report, Unified segment or other customization features.

Custom Dimensions can be used in a Custom Report, Unified segment or other customization features.

Best Practices for Managing CSV files

You might want to widen your data based on multiple keys. For example, you might want to widen your product data (using the product ID as a key) and your campaign data (using campaign name as a key).

In this case you’ll need to define two different schemas and upload two different CSV files. Make sure you name them something logical!

Another thing to consider is when to update your CSV files.

For example, let’s say that you’re a publisher, and you’re uploading new data about your content. But you’re publishing new content every day. And probably multiple times a day. You would need to upload a new CSV file every time you publish content. This is too manual. In case you probably want to consider a programmatic solution.

Use the CSV file for things that do not change often. Use the API for things that change a lot!

What about JavaScript and real-time collection?

Given my previous example, you may be asking yourself, “can’t I just collect custom data in real-time using JavaScript?”

Absolutely!

You could do something fancy, like add the data to a data layer, then pull it into some custom dimensions. No problem!

The point is that you don’t always have the time or the IT resource to implement the data collection. Even if you use a cool technology like tag management, it may be that the data you want to add comes from an isolated system. And that it would take too much effort to transport the data from it’s home all the way to the web server.

Dimension widening can be seen as a somewhat faster, less IT intensive way of joining your data together.

Things to be aware of…

Ok, a few things that you need to be aware of when using Dimension widening.

1. Your data is NOT applied to historical data. Your data is only applied going forward.

2. You can NOT widen on ALL dimensions. You can NOT widen on the following dimensions:

  • custom variables
  • product dimensions and metrics
  • campaign dimensions
  • time-based dimensions (hour, minute, etc)
  • geo-dimensions (country, city, etc)

3. If you would like to expand your dimensions and populate Custom Dimensions you MUST use Universal Analytics. The reason is that Custom Dimensions only exist in Universal Analytics. They do not exist in the previous version of Google Analytics.

4. You can not change a schema once it has been entered into Google Analytics. You must delete the schema and then define your new schema.

I know some of these caveats may seem limiting, but remember, this is just the initial version. I know the team is working hard to expand the functionality.

Do you think you will use Dimension widening? If so how? Feel free to share your examples below!

Dimension Widening: Import data directly into Google Analytics is a post from: Analytics Talk by Justin Cutroni

The post Dimension Widening: Import data directly into Google Analytics appeared first on Analytics Talk.

Bye Bye JavaScript! Auto Event Tracking with Google Tag Manager

Implementing analytics, or any type of conversion tracking, is a big pain in the ass. There, I said it! But it’s been getting easier and easier with adoption of Tag Management tools. Google Tag Manager is going to make it even easier with the introduction of a new feature called Auto Event Tracking. Auto Event […]

Bye Bye JavaScript! Auto Event Tracking with Google Tag Manager is a post from: Analytics Talk by Justin Cutroni

The post Bye Bye JavaScript! Auto Event Tracking with Google Tag Manager appeared first on Analytics Talk.

Implementing analytics, or any type of conversion tracking, is a big pain in the ass. There, I said it! But it’s been getting easier and easier with adoption of Tag Management tools. Google Tag Manager is going to make it even easier with the introduction of a new feature called Auto Event Tracking.

Auto Event Tracking let’s you track almost any user action without any additional JavaScript. It automatically captures user actions like clicks and form submissions.

TL;DR: watch this video.

For all you Google Analytics users, this means that it is no longer necessary to add JavaScript to track PDF downloads, outbound links or other user clicks. Those tasks, and many others, can be automated with Google Tag Manager.

I know – it’s exciting! Less coding = faster data collection = more reliable data quality = better insights.

There are a number of new additions to GTM that make auto-event tracking possible. Let’s take a look at how the system has changed to make this possible.

How Auto-Event tracking works

Here’s a brief overview of how the new auto-event tracking works.

Listen, Capture Collect. How the Auto-event tracking works for Google Tag Manager.

Listen, Capture Collect. How the Auto-event tracking works for Google Tag Manager.

1. Listen: A new type of tag, called an Event Listener tag, will listen for different types of user actions, like clicks or form submissions.

2. Capture: When the Event Listener tag detects an action it identifies it and captures it (technically it pushes a Google Tag Manager event onto the data layer).

3. Collect: You can then automatically collect the action using additional tags, like an analytics tag.

Remember, this all happens without any additional coding. All you need to do is add the necessary settings in GTM.

There are three new pieces of functionality that make this possible:

1. The new Google Tag Manager Event Listener tag.

2. New events that indicate a user action has occurred.

3. New macros that collect information about the user’s interaction with the content.

The Event Listener Tag & Automatic Events

Let’s start with the new tag, called The Event Listener tag. This is a special tag that – wait for it – listens for a user action on a page :)

When the tag detects an action it automatically collects the action and identifies it. From a technical perspective is pushes a Google Tag Manager event to the data layer.

There are four different types of user actions that the tag can detect. Again, each action results in a Google Tag Manager event.

Click listener: this tag will listen for clicks on a page. This includes button clicks, link clicks, image clicks, etc. When a click occurs, the Google Tag Manager event gtm.click is automatically generated.

Form listener: this tag will listen for any form submissions. When a form submission occurs the Google Tag Manager event gtm.formSubmit is automatically generated.

Link click listener: same as the click listener, except it only captures clicks on links. When a link is clicked, the Google Tag Manager event gtm.linkClick is automatically generated.

Timer listener: the timer listener will collect data at some regular interval that you specify. For example, if you specify an interval of 10,000 milliseconds, GTM will fire an event every 10 seconds.

Obviously, if you want to automatically listen for user actions you must include one of the above tags on the page where you would like to capture the user action.

For example, let’s say you want to capture clicks on outbound links (this means links to other websites). Chances are you have outbound links on all of your pages. So you should add the Link Click listener tag to all pages of your site.

Remember, to add a tag you need to specify a rule that governs when the tag is added to a page. Here’s the default rule to add a tag to all the pages on your site.

Use the GTM All Pages rule to add a common event listener to every page on your site.

Use the GTM All Pages rule to add a common event listener to every page on your site.

But let’s say you want to capture a form submission, like a contact form. There really isn’t any need to include that tag on all of your site pages. So you can create a rule to add the tag to just your form page, like this:

To control the form listener tag, restrict the placement with a rule.

To control the form listener tag, restrict the placement with a rule.

The new Events are important because they identify that an action has happened. I’ve got some example below.

Understanding the New Auto Event Macros

In addition to the new tags & events there are also a number of new macros that help collect the action that occurred.

A macro is a piece of data that you can use in your tags. Some macros are automatically populated, like the url macro (which is the url of the page), the hostname macro (which is the hostname of the site), or the referrer macro (which is the HTTP referrer).

With the Auto Event Tracking macros you can automatically add data about the element the user interacted with to your analytics tag (or any other tag).

There are five new macros that can provide elements information:

Element url: This macro stores the value of the href or action attribute of the element that triggered the event. For example, a click on the link < a href="http://www.cutroni.com">Analytics Talk< /a> would result in an value of http://www.cutroni.com.

Element target: This macro stores the value of the target attribute of the element that triggered the event. Nerd Bonus: The value is stored in the gtm.elementTarget variable in the data layer.

Element id:This macro is the value of the id attribute of the element that triggered the event. For example, a click on the link < a href="http://www.cutroni.com" id="outbound_link">Analytics Talk< /a> would result in an element id value of outbound_link. Nerd Bonus: The value is stored in the gtm.elementId variable in the data layer.

Element classes: This macro is the value of the class attribute of the element that triggered the event. Nerd Bonus The value is stored in the gtm.elementClasses variable in the data layer.

Element: This macro is also the value of the action or href attribute of the element that triggered the event.

Let’s put this all together and look at some of the common analytics tracking tasks you can implement with data layer.

Tracking Clicks

Sometimes we need to track user clicks – a click on a button, image or link. Before Auto Event Tracking we would need to add extra JavaScript to the site in order to fire analytics code. Now we just use the Click Listener tag to detect a click.

Let’s walk through how to track ALL clicks on a page and capture them with a Google Analytics event.

First, add the Click Listener tag to the necessary pages. You can add it to all pages, or just a select few. It depends on what you need to track.

The Click Listener tag will listen for user clicks and execute when a click is detected.

The Click Listener tag will listen for user clicks and execute when a click is detected.

Next, we add our Google Analytics tag to execute, and thus collect, when the click happens. Notice that I am hard-coding the Event Category to be click but the Action and Value will be dynamically populated with data from the HTML element that the user clicked on.

We can use a GTM macro to automatically capture the HTML element that the user clicked on.

We can use a GTM macro to automatically capture the HTML element that the user clicked on.

The value of the action is capturing the generic name of the HTML element. This might be [object HTMLInputElement] for a form element or [object HTMLBodyElement] for the body of the page. These are fairly descriptive and can help you understand what happened.

But a better strategy would be to capture the element class or element id. These are usually more descriptive.

Here’s the rule that determines when to acctualy collect the click. Basically it will collect EVERY click on the page using a Google Analytic event. We’ll look at a few examples later that will restrict the collection to only certain elements.

The gtm.click event indicates that a user clicked on something. This causes the Google Analytics tag to fire.

The gtm.click event indicates that a user clicked on something. This causes the Google Analytics tag to fire.

I should note that this approach will NOT work for content that is in an iFrame. For example, if you embed a YouTube video in your page, you can not capture clicks on the buttons, etc.

Using this general approach can generate a lot of data – crappy data! Let’s look at reducing the amount of data by tracking certain types of clicks.

Tracking Outbound Links

We all want to know where people go after they visit our site. Did they leave using a link in an article or did they just navigate away?

To track a click on an outbound link we follow the same general process we outlined above. The big difference is we need to make sure we only track clicks on links that go to another site.

First, we add the Link Click Listener tag to the necessary pages. Because there usually outbound links on every page, I apply the Link Click Listener tag to every page on the site.

The Link Click Listener tag will listen for user clicks on links.

The Link Click Listener tag will listen for user clicks on links.

Now we need to add an analytics tag to collect data when a click happens. Let’s use Google Analytics and collect the data in an event! Notice that I am hard-coding the Event Category value to outbound-link.

The Event Action will be dynamically filled with the destination URL. That’s the URL of the page the user will land on. This is all made possible thanks to the element url macro.

The element url macro will automatically add the destination url to the Google Analytics event.

The element url macro will automatically add the destination url to the Google Analytics event.

Here’s the important part – the tag rule. Notice that there are two parts to the rule. First I need to check for clicks on links. But I also added an additional condition that stipulates the link must not match cutroni, which is the domain of this blog. Now the Google Analytics tag will only fire and collect the click if the link is to a different domain.

Add a rule to specify what is an outbound link clicks on your site.

Add a rule to specify what is an outbound link clicks on your site.

Tracking file downloads

File downloads are very similar to outbound link clicks. I just use a different Listener tag.

Let’s just skip to the analytics tag that will collect the data.

I’m using a Google Analytics event again. The category is hard coded as file-download. The event action will be the URL of the file and it will be dynamically populated using the element url macro.

The element url macro will automatically add the PDF url to the Google Analytics event data.

The element url macro will automatically add the PDF url to the Google Analytics event data.

Just like I did with the outbound link tracking, I need to modify the rule to include a condition. The condition specifies that the user clicked on a link that contains .pdf.

To track a PDF link click add a condition to your tag firing rule.

To track a PDF link click add a condition to your tag firing rule.

Hopefully you can use this example and track clicks on any type of file that you want.

Tracking Form Submissions

Now let’s move on to forms. You could track a form using the Click listener tag. Basically you would track all of the clicks on the Submit button. But the form

We start with the Form Submission listener tag. Rather than add this tag to every page on the site, I like to only add it to pages where there is a form.

The form listener tag can be configured to delay the form submission while data is collected.

The form listener tag can be configured to delay the form submission while data is collected.

ALso notice that you can configure the form listener tag to delay the form submission to insure that the data is collected.

The tag will delay the form for up to two seconds only. Anything longer than that will create a bad user experience. GTM is smart like that :)

Just like the click tracking, there is also a form-submit event that will be generated when a user submits the form. We use this event to set up our analytics tag with a rule to control the execution.

This rule will only fire the Google Analytics event tag when a form is submitted.

This rule will only fire the Google Analytics event tag when a form is submitted.

I can actually pull some of the data in the form elements directly into my analytics tag using a macro.

For example, let’s say I have a form element named Gender. I can use a macro to capture the data, then use that macro when I define my Google Analytics Event, like this:

You can collect data from a form element using a macro and send the data to Google Analytics.

You can collect data from a form element using a macro and send the data to Google Analytics.

REMEMBER it’s not cool to collect personally identifiable information.

Here’s a bit more information on creating and using macros.

But overall, tracking a form submission is fairly straight forward. Very much like the other scenarios above.

There you have it, some of the common ways to use the new Auto Event Tracking feature.

That was a really looooong post. Hopefully it gave you a good understanding of how this feature works and how you can use it to make data collection easier to implement and maintain.

Give auto-event tracking a shot and be sure to share your experience in the comments below.

Bye Bye JavaScript! Auto Event Tracking with Google Tag Manager is a post from: Analytics Talk by Justin Cutroni

The post Bye Bye JavaScript! Auto Event Tracking with Google Tag Manager appeared first on Analytics Talk.