Google Analytics

Advanced intelligence for free.

  • PDF / 452,794 Bytes
  • 7 Pages / 504 x 720 pts Page_size
  • 30 Downloads / 235 Views

DOWNLOAD

REPORT


Google Analytics Advanced intelligence for free. Let’s look at a simple tool to better understand how our users interact with our web applications. This is a huge boon to web application developers. Building our own analytic tracker would require adding a lot of custom Flask code to every page to track users, along with a database to save those interactions and an analytical engine to make sense of it. That’s a lot of work! Instead, with Google Analytics, all we have to do is add a JavaScript snippet of code at the top of each page. That’s it; add a few generic lines to every page, no editing required, and Google Analytics will handle everything else. Google Analytics will tell us where users came from, how much time they spend on the site and on each page, the paths they take, etc. This is a must tool to not only better understand users, but also to refactor and create new content. There is a free version and a costly premium version—we’ll focus on the free one here. The free version gives you plenty of insight for small web applications like the one we’re building here.

Note  There are no downloads for this chapter.

Create a Google Analytics Account Navigate to Google Analytics to create a free account at https://analytics.google.com/ analytics/web/provision. This will show a simple graphic of the process of tracking a web page and the “Sign up” button (Figure 13-1).

393

© Manuel Amunategui, Mehdi Roopaei 2018 M. Amunategui and M. Roopaei, Monetizing Machine Learning, https://doi.org/10.1007/978-1-4842-3873-8_13

Chapter 13

Google Analytics

Figure 13-1.  The Google Analytics process and sign up Where it asks for a website name, enter you PythonAnywhere.com account (the Pair Trading one; don’t worry you can track up to 100 accounts). It will ask you a few basic questions and you can go with the defaults (Figure 13-2).

Figure 13-2.  My answers on Google Analytics Finally, click the blue button at the bottom of the page “Get Tracking ID” and accept the terms of service.

394

Chapter 13

Google Analytics

JavaScript Tracker The first page you will see once you log into your Google Analytics dashboard is the “Admin” tab with the key snippet of JavaScript needed to track a web page (Listing 13-1). This is the heart of the tracking system. You just need to add your API key where it says “” and drop this on all your pages.

Listing 13-1.  The JavaScript Tracking Snippet

Copy it and drop it in the “” section of any website you own and want to track. The head of every HTML template for the Pair Trading Booth should look like Listing 13-2 (make sure you enter yours, as this one will collect traffic analytics for my account).

Listing 13-2.  This is Mine

        Pair Trading Booth          

Reading Your Analytics Report After adding your Google Analytics tracking code to your site, save it and propagate the “Pair Trading Booth.” Point a browser to your site, view the source to make sure the new code is there, then refresh your Google Analytics Dashboard. You should see that one active user is on the site—tha