简体   繁体   English

如何使用Java获取Google Analytics(分析)数据?

[英]How to get google analytics data using java?

I am trying to download a google analytics data using java. 我正在尝试使用Java下载Google Analytics(分析)数据。 I am using a quick start code provided by google developer guide. 我使用的是Google开发人员指南提供的快速入门代码。 I downloaded oauth credential file in json format from the developer console. 我从开发者控制台下载了json格式的oauth凭证文件。 I also given the json path to program but I am getting error. 我还给出了程序的json路径,但出现错误。 Please help 请帮忙

public class HelloAnalytics {
  // Path to client_secrets.json file downloaded from the Developer's Console.
  // The path is relative to HelloAnalytics.java.
  private static final String CLIENT_SECRET_JSON_RESOURCE = "ga-data-report-7ac3499541bf.json";

  // The directory where the user's credentials will be stored.
  private static final File DATA_STORE_DIR = new File(
      System.getProperty("user.home"), "store/hello_analytics");

  private static final String APPLICATION_NAME = "Hello Analytics";
  private static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();
  private static NetHttpTransport httpTransport;
  private static FileDataStoreFactory dataStoreFactory;

  public static void main(String[] args) {
    try {
      Analytics analytics = initializeAnalytics();
      String profile = getFirstProfileId(analytics);
      printResults(getResults(analytics, profile));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

在此处输入图片说明

I think the answer is on my post: Hello Analytics API: Java quickstart errors 我认为答案就在我的文章中: Hello Analytics API:Java快速入门错误

You can check out my code there aswel. 您可以在那里查看我的代码。 I Don't just check the first profile of the first webproperty of the first account. 我不只是检查第一个帐户的第一个网络属性的第一个配置文件。 I check them all, cause more is better. 我检查所有这些,因为更多更好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 java 中使用 Google Analytics Data API (GA4) 以获取 screenPageViews 计数时扩展获取值? - how to extend the get values while using Google Analytics Data API (GA4) in java to get count of screenPageViews? 使用 Java 将数据直接发送到 Google Analytics - Sending data directly to Google Analytics using Java 使用FileWriter使用JAVA将Google Analytics(分析)数据转换为CSV文件 - Using FileWriter to convert Google Analytics data into CSV file using JAVA 使用JAVA将Google Analytics(分析)API中的数据导出为CSV文件格式 - Exporting data in google analytics api to CSV file format using JAVA 使用 Java 在 Google Analytics 上分页 - Pagination on Google Analytics using Java 如何获取访问令牌以获取谷歌分析数据? - How can I get the access token to get google analytics Data? 如何使用Google Analytics(分析)分析Java Swing应用程序 - How to analyze Java Swing application using Google Analytics 如何使用Google Analytics跟踪java servlet请求 - How to track java servlet request using Google Analytics 使用 Google Data Analytics API (ga4) 获取分析报告的 java 程序(jdk 1.8)的 maven 依赖项是什么? - What are maven dependencies for a java program (jdk 1.8) which uses Google Data Analytics API (ga4) to get analytics report? 使用Google Analytics(分析)跟踪Java版本 - Tracking Java versions using Google Analytics
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM