Package com.google.api.services.analytics.model

Examples of com.google.api.services.analytics.model.GaData


    }

    public JSONObject getProfileMetrics(String profileId) throws IOException {
        String formattedToday = DATE_TIME_FORMATTER.print(new DateTime());
        Analytics analytics = initializeAnalytics();
        GaData data = analytics.data().ga()
                .get("ga:" + profileId, formattedToday, formattedToday, "ga:visitors,ga:newVisits")
                .execute();

        if (CollectionUtils.isEmpty(data.getRows())) {
            return null;
        }


        JSONObjectBuilder builder = new JSONObjectBuilder();
        builder.add("id", profileId);
        int columnIndex = 0;
        for (GaData.ColumnHeaders header : data.getColumnHeaders()) {
            JSONObjectBuilder metric = new JSONObjectBuilder();
            String metricName = normalizeMetricName(header.getName());
            metric.add("metric", metricName);
            metric.add("id", profileId);
            Set<String> hashtags = new HashSet<>();
            hashtags.add(metricName.toLowerCase());

            for (List<String> row : data.getRows()) {
                for (int rowIndex = 0; rowIndex < row.size(); rowIndex++) {
                    if (rowIndex == columnIndex) {
                        metric.add("data", new Float(row.get(rowIndex)));
                    }
                }
View Full Code Here


    }

    private void getGAStuff(Division results) throws IOException, WingException {

        GoogleQueryManager gqm;
        GaData gaData;

        // Get the page views
        gqm = new GoogleQueryManager();
        gaData = gqm.getPageViews(startDateString, endDateString, handle);
        java.util.List<java.util.List<String>> rows = gaData.getRows();

        Table pageViews = results.addTable("pageViews", rows.size(), 2);
        pageViews.setHead(T_page_views);

        for (java.util.List<String> row : rows) {
            Row tableRow = pageViews.addRow();
            tableRow.addCellContent(row.get(0) + " / " + row.get(1));
            tableRow.addCellContent(row.get(2));
        }

        // Get the bitstream downloads
        gqm = new GoogleQueryManager();
        gaData = gqm.getBitstreamDownloads(startDateString, endDateString, handle);
        rows = gaData.getRows();

        Table bitstreamViews = results.addTable("downloads", rows.size(), 2);
        bitstreamViews.setHead(T_downloads);

        for (java.util.List<String> row : rows) {
View Full Code Here

  public static void main(String[] args) {
    try {
      HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
      DATA_STORE_FACTORY = new FileDataStoreFactory(DATA_STORE_DIR);
      Analytics analytics = initializeAnalytics();
      GaData gaData = executeDataQuery(analytics, TABLE_ID);

      printDataTable(gaData);

    } catch (GoogleJsonResponseException e) {
      System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage());
View Full Code Here

TOP

Related Classes of com.google.api.services.analytics.model.GaData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.