Generate Data with Google Analytics SQL Saturday 2019 26/04/2019
Introduction Bio Sam is the Web Services Librarian at the Edmonton Public Library (EPL), where she works with the library’s Google Analytics data. She has worked in digital libraries for 3 years, picking up data management and coding skills along the way. She holds a Masters in Library and Information Studies (MLIS) from the University of Alberta.
Background Presentation titled: “Create Open Data with Google Analytics” https://www.epl.ca/odd/
Outline Analyze data with Google Analytics Visualize data with Data Studio Export data with Google Sheets Add-On Automate with Google Apps Script
Analyze Data with Google Analytics
Google Analytics Demo Account https://analytics.google.com/analytics/web/demoAccount Link doesn’t work in Firefox! Use Chrome or Edge You will be prompted to log into your Google account If you don’t have a Google Analytics account, this will create one; if you do, the demo account will be added to your existing account
Google Analytics Reports Real-time: monitor user activity as it happens on the site Audience: high-level look at your site’s users - includes sessions (pageviews, duration), location, technology (browsers, devices, etc.) Acquisition: where your users come from to reach your site Behaviour: what your users do on your site - including what pages they view, what search terms they use, what they click, download, etc. (“events”) Conversions: view the status of goals you’ve set up
Example Report: Device Category Audience > Mobile > Overview - From a web design / development perspective, it’s good to know what devices your audience uses to access your website
Edit GA Report Example: Change date range
Visualize GA Report Select dimension(s) > Plot Rows - Limitation of visualizations in GA: limited to two dimensions
Edit GA Report Example: Add Secondary dimension Recommended secondary dimensions: browser, browser size, operating system, etc. Limited to two dimensions in GA report view
Export GA Report Can export GA reports to pdf, Google Sheets, Excel, csv
2. Visualize Data with Data Studio
Data Studio https://datastudio.google.com/data Use Chrome for best results
Connect to Google Analytics Example: Demo Account > Google Merch. Store > Master View
Create Data Studio Report Some authorization required to continue
Customize Report: Add Chart
Example Chart: Device Category DATA Data Source = GA Demo Account Time Dimension = Month of Year Breakdown Dimension = Device Category Metric = Sessions Sort = Sessions
Edit DS Report Example: Add date range
Filter Chart Add Filter > Create Filter > Save
View DS Report Can share Data Studio reports like any other Google Drive file (doc, sheet, etc.)
Download DS Report Can download as a PDF
3. Export Data with Google Sheets Add-On
Get Google Sheets Add-Ons
Create New Report Add-ons > Google Analytics > Create new report
Create Report Required Configuration Options Report Name Account Property View Metric(s) Dimension(s)* Benefit of Analytics Add-On: multiple dimensions! *Dimensions are technically not required, but they’re necessary for a meaningful report Account = Demo Account Property = Google Merch. Store View = Master View Metrics = Users, Sessions Dimensions = Device Category, Browser, Operating System
Configuration Options Additional Options Start / End Date Order Filter(s) Limit Each field is editable Filters: differ from “Limit” by including / excluding data based on the filter parameters Limit: differs from “Filters” by including results up to designated limit based on “Order” Start Date = 2018-01-01 End Date = 2018-12-31 Order = -ga:users Spreadsheet URL = copy the url of the current spreadsheet
Configuration Options: Filters https://developers.google.com/analytics/devguides/reporting/core/v3/reference#filters
Run Report(s) NOTE: Demo Account doesn’t grant sufficient permissions to access Google Analytics Reporting API Add-ons > Google Analytics > Run reports
Schedule Reports Schedule reports to automatically export data! Add-ons > Google Analytics > Schedule reports *Remember to change the start / end dates! Start Date =EOMONTH(B5,-1)+1 End Date =EOMONTH(TODAY(),-1) Example: 1st of every month
Schedule Reports Settings
Export Reports File > Download as… .xlsx .ods .pdf .html .csv .tsv
with Google Apps Script 4. Automate with Google Apps Script “Google Apps Script is a JavaScript cloud scripting language that provides easy ways to automate tasks across Google products and third party services and build web applications”
Create GAS Project in Sheets Tools > Script editor
Write Script to Create Chart
Debug & Run Script Save script Select function Click bug icon to debug Click the play icon to run NOTE: debugging will also run the script if no bugs are found!
Create Custom Menu Menus are useful for activating functions without having to open up the script editor. Also handy for those who aren’t familiar / comfortable with script editor
Add Trigger
Edit Trigger Settings After saving, we can refresh the spreadsheet to see the new menu Run function = onOpen Event source = From spreadsheet Event type = On open
Wrap-Up
Resources Scripts Tutorials Google Apps Help Analytics: https://support.google.com/docs/topic/9054603 Sheets: https://support.google.com/docs/topic/9054603 Scripts Tutorials GAS: https://developers.google.com/apps-script/articles/tutorials Codecademy – JavaScript: https://www.codecademy.com/learn/introduction-to-javascript W3schools – JavaScript: https://www.w3schools.com/js/
Thanks to Our Sponsors
Thank You! Sam Hamilton Digital Marketing Specialist Edmonton Public Library Sam.Hamilton@epl.ca