google-logo.png

Analytics Academy

Platform Principles: Data Collection Overview


Introduction

Google Analytics uses tracking code to collect data. It doesn’t matter if you are tracking a website, mobile app or other digital environment -- it’s the tracking code that gathers and sends the data back to your account for reporting.

Using hits to collect and send data

Simply put, the tracking code collects information about a user’s activity. The information that’s collected is packaged up and sent to the Analytics servers via an image request. This image request is the “hit.” It’s the vehicle that transmits the data from your website or mobile app to Google Analytics.

Let’s look at an example of a small portion of an image request.

http://www.google-analytics.com/__utm.gif?utmwv=4&utmn=769876874&utmhn=example.com

&utmcs=ISO-8859-1&utmsr=1280x1024&utmsc=32-bit&utmul=en-us&utmje=1&utmfl=9.0%20%20

r115&utmcn=1&utmdt=GATC012%20setting%20variables&utmhid=2059107202&utmr=0&utmp=/au

to/GATC012.html?utm_source=www.gatc012.org&utm_campaign=campaign+gatc012&utm_term=

keywords+gatc012&utm_content=content+gatc012&utm_medium=medium+gatc012&utmac=UA-30

138-1&utmcc=...

In the example, everything after the question mark is called a parameter. Each parameter carries a piece of information back to Google’s analytic servers. Some of these parameters are encoded and can only be interpreted by Google Analytics. Others are actually human readable, like the parameter utmul=, which shows the language that the user’s browser is set to (in this case, en-us, which is US English).

How tracking works

Depending on the environment you want to track -- a website, mobile app, or other digital experience -- Google Analytics uses different tracking technology to create the data hits. For example, there is specific tracking code to create hits for websites and different code to create hits for mobile apps.

In addition to creating hits, the tracking code also performs another critical function. It identifies new users and returning users. We’ll explain how the tracking code does this in later lessons.

Another key function of the tracking code is to connect your data to your Google Analytics account. This is accomplished through a unique identifier embedded in your tracking code.

Here is an example of what the tracking ID looks like:

<!-- Google Analytics -->

<script>

(function(i,s,o,g,r,a,m){i[GoogleAnalyticsObject]=r;i[r]=i[r]||function(){

(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)

})(window,document,script,//www.google-analytics.com/analytics.js,ga);

ga(create, UA-12345-6, auto);

ga(send, pageview);

</script>

<!-- End Google Analytics →

For your own account, you can find the tracking ID in the account administrative settings.

Conclusion

In summary, no matter what environment you’re tracking, all Google Analytics data collection works the same way. The tracking code collects and transmits user activity data, identifies new and returning visitors, and associates all of this data to your specific account.

Complete the lesson activity

>> Visit the activity for this lesson now


google-logo.png

Analytics Academy

Platform Principles: Website Data Collection


Introduction

Google Analytics uses different tracking technology to measure user activity depending on the specific environment you want to track -- websites, mobile apps, or other digital experiences. To track data from a website, Google Analytics provides a standard snippet of JavaScript tracking code. This snippet references a JavaScript library calledanalytics.js that controls what data is collected.

Adding the Google Analytics JavaScript code to your website

You simply add the standard code snippet before the closing </head> tag in the HTML of every web page you want to track. This snippet generates a pageview hit each time a page is loaded. It’s essential that you place the Google Analytics tracking code on every page of your site. If you don’t, you won’t get a complete picture of all the interactions that happen within a given website session.

When a user views a page on your site, the web browser begins to render the HTML on the page. It starts at the top of the page and moves towards the bottom. When it gets to your Google Analytics tracking code, the browser automatically triggers the JavaScript. Adding the code snippet to the top of the page, before the closing </head> tag, ensures that the Google Analytics code runs, even if a user navigates away from a page before it fully loads.

Functions of the web tracking code

The Google Analytics tracking code executes JavaScript asynchronously, meaning that the JavaScript runs in the background while the browser performs other tasks. This is very important -- it means that the Google Analytics tracking code will continue to collect data while the browser renders the rest of the web page.

As the tracking code executes, Google Analytics creates anonymous, unique identifiers to distinguish between users. There are different ways an identifier can be created. By default, the Google Analytics JavaScript uses a first-party cookie, but you can also create and use your own identifier.

When a page loads, the JavaScript collects information from the website itself, like the URL of the current page. The JavaScript also collects information from the browser, such as the user’s language preference, the browser name, and the device and operating system being used to access the site. All of this information is packaged up and sent to Google’s servers as a pageview hit. This process repeats each time a page is loaded in the browser.

Conclusion

That’s it! That’s how basic website tracking works. The standard JavaScript code snippet provides a simple way to track user activity from a website, and collects most of the data you’ll need without any customization. But keep in mind that there are many ways to customize your code to capture additional information about your users, their sessions and the interactions with your site.

Complete the lesson activity

>> Visit the activity for this lesson now



google-logo.png

Analytics Academy

Platform Principles: Mobile App Data Collection


Introduction

With Google Analytics, you can collect and analyze data about your mobile app, just like you can with your website. However, since the technology to build and run mobile apps is different than the technology used to build websites, there are differences in how Google Analytics collects data from mobile apps.

Using the Google Analytics mobile SDKs

Instead of using JavaScript to collect data like you do on a website, youll use an SDK, or Software Development Kit, to collect data from your mobile app. There are different SDKs for different operating systems, including Android and iOS.

SDKs collect data about your app, like what users look at, the device operating system, and how often a user opens the app. This data gets packaged as hits, and sent to your Google Analytics account. This is similar to how the JavaScript code sends hits from a website.

Dispatching

Data from mobile apps is not sent to Analytics right away. When a user navigates through an app, the Google Analytics SDK stores the hits locally on the device and then sends them to your Google Analytics account later in a batch process called dispatching.

Mobile data collection uses dispatching for two reasons:

  • First, mobile devices can lose network connectivity, and when a device isn’t connected to the web, the SDK can’t send any data hits to Google Analytics.
  • Second, sending data to Google Analytics in real time can reduce a device’s battery life.

For these reasons, the SDKs automatically dispatch hits every 30 minutes for Android devices and every two minutes for iOS devices, but you can customize this time frame in your tracking code to control the impact on the battery life.

Differentiating users on mobile

Another important function of the mobile SDK is differentiating users. When an app launches for the first time the Google Analytics SDK generates an anonymous unique identifier for the device, similar to the way the website tracking code does. Each unique identifier is also counted in Google Analytics as a unique user.

If the app gets updated to a new version, the identifier on the device remains the same. However, if the app gets uninstalled, the Google Analytics SDK deletes the identifier. If the app is then reinstalled, a new anonymous identifier is created on the device. The result is that the user will be identified as a new user, not a returning  user, but no other data in your Google Analytics reports will be impacted.

Conclusion

The mobile SDKs provide a simple way to track user activity from an app, and collect most of the data you’ll need without any customization. But keep in mind, there are many ways to modify your code to collect additional information about your users, their sessions and their interactions with your app.

Complete the lesson activity

>> Visit the activity for this lesson now



google-logo.png

Analytics Academy

Platform Principles: Measurement Protocol Data Collection


Introduction

In previous lessons, we’ve seen how websites use JavaScript and mobile apps use SDKs to send data to Google Analytics. But what if you want to collect data from some other kind of device? For example, you might want to track a point-of-sale system or user activity on a kiosk.

Collecting and sending data with the Measurement Protocol

The Measurement Protocol lets you send data to Google Analytics from any web-connected device. Recall that the Google Analytics JavaScript and mobile SDKs automatically build hits to send data to Google Analytics. However, when you want to collect data from a different device, you must manually build the data collection hits. The Measurement Protocol defines how to construct the hits and how to send them to Google Analytics.

For instance, let’s say we want to collect data from a kiosk. Here’s a sample hit that will track when a user views a screen on the kiosk:

http://www.google-analytics.com/collect?v=1&tid=UA-XXXX-Y&cid=555&sr=800x600&t=pageview&dh=mydemo.com&dp=/home&dt=homepage

Notice there is a parameter in the hit that contains the screen resolution. This particular parameter will become the dimension Screen Resolution during processing. The  value in the parameter will end up in the Screen Resolutions report.

Like the JavaScript and mobile SDKs which include a tracking ID with each hit, you must also add a tracking ID to every hit you send to Google Analytics. This will ensure that the data appears in your specific Analytics account and property. All of the parameters that you can include in the hit are explained in the Analytics Developer documentation.

Conclusion

With the Measurement Protocol, you can use Google Analytics to collect data from any kind of device. And, as more and more technologies and digital devices come to market, you’ll be able to continue to use Google Analytics to measure your success.

Complete the lesson activity

>> Visit the activity for this lesson now

Posted by Name_null