IvanKolyago131 / r-google-analytics

Automatically exported from code.google.com/p/r-google-analytics
0 stars 0 forks source link

fromJSON Error in GetSegments() #19

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Following the Example-Code for Version 1.4
2. Making every step work until ga.segments
3. ga.segments <- conf$GetSegments()

What is the expected output? What do you see instead?

Error en fromJSON(api.response.json, method = "C") : 
  unexpected escaped character '\.' at pos 21

What version of the product are you using? On what operating system?

Version 1.4 and Windows 7 on R 3.0.1

Please provide any additional information below.

Original issue reported on code.google.com by timvuell...@gmail.com on 11 Nov 2013 at 7:30

GoogleCodeExporter commented 8 years ago
Same exact scenario for me, following the ReadMe example code and all. 

My error message is slightly different: 

Error in fromJSON(api.response.json, method = "C") : 
  unexpected escaped character '\s' at pos 15

Version 1.4 (installed into RStudio 0.98.490 with R x64 3.0.2 installed) on a 
Windows 7 64 bit

Given the error message, I even went through my GA account and renamed all of 
my segments, replacing any possibly-sensitive characters (spaces, ampersands, 
etc.) with dashes, hoping that would fix the issue, but that did not fix the 
problem. 

Original comment by eatmorg...@gmail.com on 27 Dec 2013 at 3:14

GoogleCodeExporter commented 8 years ago
I have the same problems.

someone has the solution?

Original comment by c...@noise-media.com on 6 Jan 2014 at 2:08

GoogleCodeExporter commented 8 years ago
It looks like it has to do with the encoding of segments that use regex.  

I have a custom segment that is defined as this: 
ga:hostname=~^m\.

It is encoded on 
https://www.googleapis.com/analytics/v3/management/segments?access_token=... 
like this: 
ga:hostname=~^m\\.

I don't know how to fix it.

Original comment by jimmykgl...@gmail.com on 9 Jan 2014 at 5:11

GoogleCodeExporter commented 8 years ago
Here's a fix that appears to be working for me.
From the R Console:
fix(fromJSON)
Change the first line to this: 
function (json_str, file, method = "C", unexpected.escape = "keep")

The original error was caused by having unexpected.escape = "error"  I think 
the error stems from how R handles/interprets backslashes in Windows.  

Cheers!
Jimmy

Original comment by jimmykgl...@gmail.com on 17 Jan 2014 at 4:32

GoogleCodeExporter commented 8 years ago
Assign a segment for your query like this: 
segment <- ga.segments$segmentId[22]

Original comment by jimmykgl...@gmail.com on 17 Jan 2014 at 4:37