Google Analytics Integration (paid addon)

Posted in: Modules and Extensions

This integration allows users (who posted an Ad) and administrators view statistics about page views and time spent on the site in a chart.

In order to use the add-on, you first need to purchase it and then install as any other plugin from wp-admin / Plugins / Add New / Upload panel.

Creating Google API Project

Once you have it installed you will need to create a Service Account and allow it to access your Google Analytics data, only then it will be possible to display the Analytics data on your site.

Go to Google Developers Console, find “Create a Project” button it should be somewhere at the top (cannot tell for sure as Google is changing this interface quite often, for more details refer to Google API Create a Project documentation).

After creating the project you will need to create a Service Account which will be able to access Google Analytics and enable the Google Analytics API.

Service Account

In the left sidebar, you should see Credentials link, click it the go to Create Credentials and then Service Account Key. In the form select “Compute Engine default service account” and JSON. Creating the account should automatically download a JSON file to your computer (we will use it later). One last thing we will need here is service account email

One last thing we will need here is service account email, go to the Credentials panel and click “Manage Service Account” (or something similar) you should see there your service account email, it will look similar to this 000000000000-compute@developer.gserviceaccount.com, copy it somewhere safe.

Enable Analytics API

While on the main screen of your Google API project, click Library in the left sidebar, search for Analytics API and enable it.

Add Service Account to Google Analytics

With the email address, you copied earlier, go to your Google Analytics account, click Admin / User Management and add your service account email to the users list, now we are ready to configure the Google Analytics for WPAdverts.

Plugin Configuration

Blank Configuration Form in wp-admin / Classifieds / Options / Analytics

Blank Configuration Form in wp-admin / Classifieds / Options / Analytics

There are three fields in the configuration form

  • Application Name – you can enter here any name you wish, it will only be used to help identify your application.
  • Service Email – the email address you copied earlier
  • Key – the key is in the file that was downloaded to your computer when you created a Google API Project, find it on your computer and open in a text editor like Notepad (do not use MS Word), copy the whole content and paste it into the Key field.

After filling the form click “Save” button, if the information was entered correctly you should see a form like on the below image.

WPAdverts Google Analytics configuration, step #2

WPAdverts Google Analytics configuration, step #2

Now you just need to select a service, that is a website which data you wish to use, or in other words a website on which this plugin is installed, so if you have the WPAdverts Google Analytics integration installed on https://demo.wpadverts.com/ then select this site and save the form again.

Using The Google Analytics Integration

The Google Analytics should now be available for Administrator in wp-admin / Classifieds panel while editing an Ad as a sidebar widget and a chart with a customizable date range (you can see it after clicking on the “View Chart …” button.

Quick stats in Classified Edition

It will also be available to users in the frontend when viewing single Ad details page and a more detailed stats similar to the one in wp-admin panel will be available in the [adverts_manage] panel.

Chart in [adverts_manage]

NOTE the stats on Ad details pages are being cached once an hour to avoid going over the Google Analytics API limits (which is 5000 API calls per day for free accounts).