[MUSIC PLAYING]
SPEAKER: Welcome to part 3 of a six-part series
about creating automatic web traffic reports.
For other videos in this series, check out
the links in the description.
But for now, let's dive back in.
You've installed the Google Analytics add-on
and created a new report.
In this step, you will use a custom menu
to gather data about your website's performance
over the course of time.
You will pull data about this week, last week, this year,
and last year.
This tool will also tell you which
browsers people most commonly used to view your website
and where these people are located.
This information can help you decide
how to use your marketing budget or what
changes to make on your site.
Since you copied the spreadsheet from the starter project linked
in the instructions, the sheet already
contains Apps Script code that gathers data about your website
traffic.
For example, you may notice a new menu
in the spreadsheet toolbar.
Open the Script Editor to view the code that
created this menu.
This code contains three instructions
that you will use to create your dashboard.
The first section of code uses a trigger.
A trigger directs Apps Script to run a function automatically
when a certain event, like opening a document, occurs.
This trigger is called onOpen.
It begins a certain action as soon
as the spreadsheet is opened.
In this case, the trigger creates a custom menu
upon the opening of the spreadsheet.
The menu should be called Analytics Helper.
The code also populates the menu with options.
This menu will contain the options Set Up Data
and Create Summary.
The second portion of the code runs the function
that was added to the menu in the first part of the code.
As you saw above, the code added a menu option
called Set Up Data.
This function designs the spreadsheet
with prearranged instructions for arranging information
from Google Analytics.
To see this code at work, you first
need to grant permission for your Apps Script code to run.
This only happens the very first time you run the script.
Now that Google Analytics can connect to your spreadsheet,
set up the data.
Google Sheets will complete a report that details your page
views over time, the top browsers
responsible for those views, and the top countries
where people view your site.
To create this manually, you would
need to copy the information from the first column
and adjust all of the figures cell by cell.
However, with only a small bit of code,
you can automate this setup process
so that you can find the right information quickly.
The second portion of the code contains instructions
for modifying the data in the spreadsheet.
For example, it instructs the sheet
to modify the title in cell G2 so that it says Top countries.
The code also gathers information
by creating a series of formulas in the spreadsheet.
For example, this formula identifies the current date.
Now, use the information designed by the code
to run a new report.
When the report is complete, the Google Analytics add-on
creates six new tabs.
Each tab displays data based on the report configuration
you created in the previous step.
By completing this section, you have
accessed the Custom Analytics helper
menu designed by the code, given your permission for Google
Analytics to work with your spreadsheet,
and used the custom menu to set up the data and run a report.
Then, move on to the next video to create a report dashboard.
[MUSIC PLAYING]