How to solve “illegal character” error when saving Google Script for Google Analytics

倾然丶 夕夏残阳落幕 提交于 2019-12-11 08:36:02

问题


I'm working on automating Google analytics to get results into a google drive dashboard and coming up with an error code in "illegal character. (line 7, file "code")" How do i fix this problem? Here is the full script. I appreciate the help in advance. Thanks.

// Get Data.
var results = Analytics.Data.Ga.get(
    tableId,
    startDate,
    endDate,
    'ga:visitors,ga:visits,ga:pageviews',
    {‘dimensions’: ‘ga:date’});

// Output to spreadsheet.
var sheet = SpreadsheetApp.getActiveSpreadsheet().insertSheet();
sheet.getRange(2, 1, results.getRows().length, headerNames.length)
    .setValues(results.getRows());

// Make Sandwich.

回答1:


Not sure if line 7 in the error message is the same line 7 in the code you pasted, but if it is, then it looks like the single quotes are different. Use the straight single quote ('), and not the curvy one.

Here's what I mean:

{‘dimensions’: ‘ga:date’});

should be

{'dimensions': 'ga:date'});

Hope this helps.



来源:https://stackoverflow.com/questions/25272501/how-to-solve-illegal-character-error-when-saving-google-script-for-google-anal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!