Gauge community site usage with Google Analytics in Experience Cloud!

Pranaya Bhoyar
Cloudwerx
Published in
6 min readJun 29, 2022

--

There might be a situation wherein, the admin needs to know the number of people who visited the community site and what activities users have performed on the site, for analysis purposes. It will be helpful if the admin gets a report/data on a daily, weekly basis on the community site usage.

To track the community site usage for a few pages like the number of visits per site page and a number of clicks on links, button clicks, and Knowledge articles visited from the community site we can choose one option which is Google Analytics to track usage of each of this page.

It is really easy to configure by just point and click in 2 parts :

  1. Configuration in Google Analytics
  2. Configuration in Salesforce for Experience Cloud

Let's explore both the options in detail :

Configuration in Google Analytics :

  1. Create a Google Analytics account by logging into your Gmail account. If you are already logged in then click on the Start Measuring button.

2. There will be three options for the setup

a. Account Setup: Enter Account Name -> scroll down and click the Next button.

Account Setup

b. Property Setup: Enter Property Name -> Click on Show Advance Options -> Enable Create a Universal Analytics property -> Enter Website URL (It should be the base URL of your community site page) -> Click Next button.

c. Complete About your Business section -> Click Create

d. Close Web Stream detail Page.

e. Save My Email Communication setting.

3. After completing the above steps, you will see the below screen, if it is not visible then click on the Admin button which is there in the bottom left corner of the page.

Click on the dropdown highlighted as a “2” point in below screenshot -> Select property that has an id that starts with UA

This is the universal analytic property that will give us tracking Id, and this is required in Salesforce to configure in a Community site.

4. In the Property column, scroll down -> Click on Tracking info -> Click Tracking code.

Copy Tracking Id and Global Site Tag (gtag.js) and keep it with you in notepad.

5. In Property column, scroll down -> Click on Custom definitions option -> Custom Dimension.

You can use Custom Dimension to collect and analyze data that Analytics doesn’t automatically track, such as the information from Salesforce.

a. Click New Custom Dimension Button-

i. Name = User Type

ii. Scope = Hit

iii. Active = True -> Click Create -> Click Done

b. Click New Custom Dimension Button again

i. Name = Salesforce Object

ii. Scope = Hit

iii. Active = True -> Click Create

We have to follow the same sequence in the Community site of Salesforce.

6. Create a User Experience view. Below are the steps, this is to view the real-time report for the view of your website.

7. Enter Reporting View Name as a User Experience -> Click Create View button.

Configuration in Salesforce :

  1. Login to your Salesforce org -> Go to setup -> search for All sites and click on it -> Open Builder for your site which you want to track.

2. Click on the setting for your Community -> Click Security and Privacy option and update the CSP security level as mentioned in the below snippet.

If you use script resources hosted outside Salesforce, select Relaxed CSP, and allow the third-party hosts in the Trusted Sites for Scripts area that appears and for Google Analytics we need to configure there site in Experience Cloud.

3. Set your Google Analytics Tracking ID and Google site tag by following the steps mentioned in the below screenshot.

This is required to configure in Salesforce, which will allow Google Analytics to track activity in your site.

a. Tracking Id which is copied from the Google Analytics from step 4.

b. Global Site Tag (gtag.js), paste code on click of Edit Head Markup button and Save.

c. Set up Custom Dimensions as mentioned in the below format. Make sure the index should match the Google Analytics configuration custom dimensions.

4. Finally Publish your site with the new changes.

5. Check trusted sites should be configured correctly in Communities, follow the steps as shown in the below picture and confirm if the below links are configured correctly, if not then click on the button Add Trusted Site and add all below links one by one.

Why it is important :
To use third-party APIs that make requests to an external (non-Salesforce) server, add the server as a CSP Trusted Site.

https://www.google-analytics.com
https://www.googletagmanager.com/gtag/js https://www.googletagmanager.com

Analytics in action :

· Visit your Community site and click on any link or page within the site to track it in real-time.

· Check in Google Analytics, in Reports -> Realtime -> Content

  1. To create a custom report in Google Analytics to view the site activity later, please follow the below steps.
  2. Go to the analytics solution gallery
  3. Search for Google Analytics for Salesforce Communities
  4. Click on it and import -> Select View: User Explorer.
  5. Click on Create button for your Google Analytics account, it will create a custom report automatically from where users can track their site visits.
Report to show the pageviews

Conclusion :

And that’s about it! So as you can see it is quite easy to track the data of your community site without any code, by just following these configuration steps!
Happy Analysis!

--

--