jerseyanalyticsvisitor-statistic

How do I show visitor count in my page using google analytics?


How do I show visitor count on my home page using google analytics?

I want this in my Jersey web application.

Thanks.


Solution

    1. Go to https://code.google.com/apis/console
    2. Click 'Create Project'
    3. Create a credentials - OAuth 2.0 Client ID
    4. Select Application Type: Web application.
    5. Under IAM & ADMIN, select 'Service Account' and create Service Account.

      • Select role to project -> owner.
      • Check 'Furnish a new private key' and select P12.(it will download this file).
    6. Copy this service account id.

    7. Log in to your Google Analytics account
    8. Click 'Admin' in the bottom-left corner
    9. Click the 'User Management' tab
    10. paste this service account id in add permission field and click Add button.

    11. Set up the sample https://developers.google.com/analytics/devguides/reporting/core/v3/quickstart/service-java

    12. Set the service account and path to the p12 file.

    13. Run the Program.