Search This Blog

Tuesday, November 13, 2018

Google analytic profile id usage example

Profile Id is the number at the end of the ERL starting with p
https://www.google.com/analytics/web/#home/a11345062w43527078pXXXXXXXX/

An example to use the profile Id in the Analytics API:

//Building an API query
        Get apiQuery = analytics.data().ga().get(
                "ga:54014919",//TABLE_ID, // "ga:" + Profile Id.
                "2014-09-01", // Start date.
                "2014-09-30", // End date.
                "ga:visits,ga:pageviews");      // Metrics.

        apiQuery.setDimensions("ga:source,ga:medium");
        apiQuery.setFilters("ga:medium==referral");
        apiQuery.setSort("-ga:visits");
        apiQuery.setSegment("gaid::-11");
        apiQuery.setMaxResults(50);