Google Analytics

Google Analytics Configuration

The application has a basic visitor analytics system builtin. But if you want to use Google Analytics then the application can get your Google Analytics data on your admin dashboard and report section in place of the built-in system. By configuring Google Analytic API you can see Page views, Sessions, Unique visits, Referrals, and Behaviors of visitors on your marketplace admin dashboard. Before enabling Google Analytics you must configure the application correctly to get the Analytics data.

 

Warning! Enabling Google Analytics can cause errors if not configured or misconfigured!

 

Get API credentials

The first thing you’ll need to do is to get some credentials to use Google API. I’m assuming that you’ve already created a Google account and are signed in. Head over to Google API’s site and Select your project. If you don’t have any then create a new project and select. Now click ENABLE APIS AND SERVICES on the Dashboard section.

 

 

Next, in the list of available API’s select Google Analytics API. On the next screen click ENABLE button.

 

 

Now that you’ve created a project that has access to the Analytics API it’s time to download a file with these credentials. Click Credentials in the sidebar. Click Create credentials and choose Service account key from the dropdown list.

 

 

On the next screen click over the New service account field and give the service account a name on the Service account name field and set the Role as project Owner. You can name it anything you’d like. Copy the email address in the service account id, we’ll use this email address later on in this guide. Select JSON as the key type and click Create button. A JSON file will be download to your computer, we’ll use this file to connect with Google.

 

Now you have the API credentials on your local computer’s download location. Rename the file to analytics-api.json and upload to the file to your project at the ../storage/app/ directory.

 

Grant permission and Get the View ID

If you don’t have a Google Analytics account, create one from Google Analytics site. Go to Admin section from the sidebar and click User Management

 

 

Now click the  button and then select Add new users

 

 

On the next screen in the Email addresses field pest the client_email email address from the analytics-api.json we got from the Google API site. Check the Read & Analyze and click Add to finish.

 

 

TIPS: If you forgot to copy the service account id email address, you can get it from the JSON file you downloaded in the previous step.

 

Go back to Admin section again and click View Settings. We need the View ID displayed there.

 

 

Open the .env file and update ANALYTICS_VIEW_ID with the value you got from Google.

.
.
.
ANALYTICS_VIEW_ID=your_view_id
.
.
.

 

We’ve done the Google Analytics configuration and ready to view the Analytics on the application Dashboard. To enable Google Analytics navigate to:

 

settings system settings reports

Note: Only admin level user can see Google Analytics reports.

 

Was this helpful to you?

Leave Comment