Some groups my choose to track user visits to their site. We support two options: Google Analytics (useful for anyone) or Facebook Analytics (useful for those buying paid Facebook ads for their site's content).
For either option, you will need to create an account and obtain an id that is used to connect your site to the analytics platform. If this is for a department web site, you may want to use a shared account for setting up your account so that more than one person can log in and look at the results - or can take over managing the analytics in your absence.
To collect analytics via Google Analytics, you will need to create a Google analytics account and follow the instructions on this page to obtain a Universal Analytics tracking id. The id you need will be in the "Property Settings" section of your analytics admin interface and should be formatted as "UA-<7digits>-1". Once you have that tracking id, you can copy it into the "Google Analytics Tracking ID" field and save.
If you would like to use the full power of Google Analytics (filtering, tracing user sessions, etc.), you will want to monitor your site on https://analytics.google.com/ so there is no need to enter the "Google Analytics View ID" or the "Google Analytics Private Key JSON File". Those are used if you want to view a limited set of analytics from within the admin interface of your site.
Google Analytics within your site
If you configure the "Google Analytics View ID" and upload the "Google Analytics Private Key JSON File", an additional menu item will appear in the left hand menu. When you click on the "Analytics" item, you will be able to view some basic statistics on page views - as shown in the image at the bottom of this page.
Creating a View ID and Private Key JSON file.
This is a complex and sometimes fragile process (Google changes the details of the workflow on a regular basis, so these instruction may not be 100% accurate). You should really only do it if you really want to view analytics data directly within your site's admin console, rather than going to the Google Analytics site to view it. In addition, Analytics displayed in your Admin console will be delayed by about 24 hours, while you can see real-time data on the Google Analytics site.
Step 1 - Create a Google Service Account
- Go to https://console.cloud.google.com/iam-admin/serviceaccounts and click Create to create a new Project.
- Choose a Project name and click Create.
- Wait for the spinner to finish, then click + Create service account when it comes up.
- Choose a Service Account name and a Service account Description, and click Create
- Choose Owner from the Project submenu of the Select a Role dropdown, and click Continue.
- Click + CREATE KEY, then click CREATE from the side-menu that pops up.
- Close the "Private key saved to your computer" dialog and click DONE.
Your browser just downloaded a .json file when the dialog was displayed. You'll upload this file to your Site in Step 5. This file is the only copy of your "private key", which is how your site identifies itself with Google. Keep it safe from prying eyes and do not lose it.
Step 2 - Give your Service Account access to the Analytics API
- Click the hamburger menu in the upper left corner of the window, and choose APIs & Services from the menu.
- Near the top left you'll see a blue link called + ENABLE APIS AND SERVICES. click that, then search for Analytics API.
- Select the Google Analytics API and box from the search results.
- Click the blue ENABLE button, and wait for the spinner to finish.
Now, repeat Step 2 for the Google Analytics Reporting API.
Step 3 - Add Google Analytics to your Google Account
- Return to the Service Accounts admin page by clicking the hamburger in the upper-left, choosing IAM & admin, and then clicking Service accounts in the left sidebar.
- Copy the Email, which is an email address that Google created for this account. We'll use it in Step 4.
- Go to http://analytics.google.com then click Admin in the lower left.
- You'll now see three columns. In the left one, click + Create new account.
- Fill in the Account name field with the Project name you chose in Step 1 then click Next.
- Click Next, then choose Web from "What do you want to measure?" and click Next.
- Fill in the Website Name with the name of your site, and fill in the Website URL with the domain name of your site (e.g. myproject.sites.caltech.edu).
- Click Create.
- Accept the Terms of Service.
- You'll be presented with a page that shows your Tracking ID at the top. It looks something like UA-#######-1. Copy that value for use in Step 5.
- Click the "left arrow" icon to the left of "Property Settings" to exit the Property Settings dialog and return to the three columns.
- In the right-most column, click View Settings.
- Copy the View ID (it looks like ######) for use in Step 5.
- Return to the 3 columns view by clicking the "left arrow" again.
Step 4 - Add your Service Account as a Google Analytics User
- In the left column, click Account User Management.
- In the far upper-right, click the circular blue + button and choose Add users from the menu.
- Paste the email address you copied at the beginning of Step 3 into the Enter email addresses field.
- Check the box for the Read & Analyze permission.
- Click the blue ADD button at the top-right.
- Your Google Analytics service is now configured to allow your Service Account to retrieve information about your site's analytics.
Step 5 - Configure your Site to use your Google Analytics Account
- Log in to your site's admin console.
- In the sidebar, click Settings and then Site Preferences.
- Select the Analytics tab at the top to view the Analytics settings form.
- Paste the Tracking ID and View ID that you copied in Step 3 into the appropriate fields.
- Click the Choose File button for the Google Analytics Private Key JSON File field and select the .json file you downloaded in Step 1.
- Click the green SAVE button.
That's it! Your site is now configured to report analytics data to Google. You can view real-time analytics on your Google Analytics admin console (https://analytics.google.com/analytics/web/, then click Realtime -> Overview).
You can also view analytics for visits over the last month on your site's own admin console by clicking the Analytics link in the sidebar. Note that that page cannot display analytics from less than 24 hours ago, so you won't see anything on there until a day after you've finished this setup.
Google Tag Manager and Facebook Pixel
The Analytics settings tab has fields for you to enter a Google Tag Manager ID and / or a Facebook Pixel ID. These are both advanced analytics tools that require a fair amount of expertise to use effectively. Assistance with these tools is beyond the scope of support IMSS can provide.