简体   繁体   English

如何将Google Analytics(分析)API响应放入表格中?

[英]How to put Google Analytics api response in a sheet?

I want to import Google Analytics remarketing Audiences into a spreadsheet. 我想将Google Analytics(分析)再营销受众群体导入电子表格。 I get the response from Google Analytics Management API, but I cannot get my head around on how to parse this and get it into a spreadsheet. 我得到了Google Analytics Management API的响应,但是我无法全力以赴地分析如何将其解析为电子表格。

    function getlists() {
      var ss = SpreadsheetApp.getActiveSheet();
      var acc = XXX;
      var prop = "UA-XXX-1";
      var lists = Analytics.Management.RemarketingAudience.list(acc,prop)
      Logger.log(lists.items)
    }

The response is as follows: 响应如下:

{kind=analytics#remarketingAudience, created=2016-07-04T16:40:12.601Z, description=Transakcje > 0, webPropertyId=UA-XXX-1, audienceDefinition={includeConditions={kind=analytics#includeConditions, segment=sessions::condition::ga:transactions>0, membershipDurationDays=30, isSmartList=false}}, accountId=XXX, linkedViews=[XXX], name=Google shopping kupili, id=XXX, audienceType=SIMPLE, updated=2016-07-04T16:40:49.145Z, internalWebPropertyId=XXX, linkedAdAccounts=[{remarketingAudienceId=XXX, eligibleForSearch=true, accountId=XXX, linkedAccountId=DELETED, kind=analytics#linkedForeignAccount, id=XXX, type=ADWORDS_LINKS, internalWebPropertyId=XXX, webPropertyId=UA-XXX-1, status=CLOSED}]} {kind = analytics#remarketingAudience,创建= 2016-07-04T16:40:12.601Z,描述= Transakcje> 0,webPropertyId = UA-XXX-1,受众定义= {includeConditions = {kind = analytics#includeConditions,segment = sessions: :condition :: ga:transactions> 0,membershipDurationDays = 30,isSmartList = false}},accountId = XXX,linkedViews = [XXX],名称= Google购物kupili,id = XXX,受众类型= SIMPLE,更新时间= 2016-07- 04T16:40:49.145Z,internalWebPropertyId = XXX,linkedAdAccounts = [{remarketingAudienceId = XXX,qualifiedForSearch = true,accountId = XXX,linkedAccountId = DELETED,种类= analytics#linkedForeignAccount,id = XXX,类型= ADWORDS_LINKS,internalWebPropertyId = XXX,webPropertyId = = UA-XXX-1,状态= CLOSED}]}

I would like to put this response into a spreadsheet where it would be outlined: 我想将此响应放入一个电子表格中,在其中进行概述:

Kind | Created | Description | etc.

A | B | C | D

I cannot wrap my head around, how to achieve this. 我无法解决这个问题。

Solved. 解决了。

  var items = lists.items;
  var temp = [];
    temp.push(["id","name","kind","IncludeKind","IncludeIsSmart","IncludeSegment","membershipDurationDays"]);

  for(var i=0;i<items.length;i++){
    temp.push([items[i].id,items[i].name,items[i].kind,items[i].audienceDefinition.includeConditions.kind,items[i].audienceDefinition.includeConditions.isSmartList,items[i].audienceDefinition.includeConditions.segment,items[i].audienceDefinition.includeConditions.membershipDurationDays]);
  }

  ss.getRange(1, 1, temp.length, 7).setValues(temp);
`

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

相关问题 获取谷歌分析 Api 响应 - Get google analytics Api response 我如何 Map API 响应 Google 表 - How do I Map API response to Google Sheet Google Analytics API的JSON响应 - JSON response from Google Analytics api Google Sheet API,PUT:this.http.put(…).map不是函数 - Google Sheet API, PUT: this.http.put(…).map is not a function Google Drive Api v3如何使用Google表格格式上传? 400响应 - Google Drive Api v3 how can I upload with google sheet formatting? 400 response 使用 Google API 创建电子表格时在工作表上设置权限 - Put permissions on a sheet when create a spreadsheet with Google API 如何在从 API 响应中设置值时避免覆盖谷歌表中的一行 - How do I avoid overwritting a row in google sheet while seting values from API response 在api POST响应成功后,如何以编程方式衡量通过Google跟踪代码管理器向Google Analytics(分析)的购买? - How do I programmatically measure a purchase to Google Analytics through Google Tag Manager after a successful api POST response? 如何通过 Google Sheet API 为 Google Sheet Cell 指定颜色 - How to specify colors for a Google Sheet Cell through the Google Sheet API 无法从Google表格中的自定义功能输出或保存API响应 - Unable to output or save API response from custom function in Google sheet
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM