Search code examples
javascriptgoogle-visualizationgoogle-analytics-api

Format Google Analytics yearMonth dimension using Google Charts


We're using the dimension ga:yearMonth and we can't seem to find a way to convert that date to something more readable, like "November 2014" instead of "201411".

Here's the dimension documentation:

https://developers.google.com/analytics/devguides/reporting/core/dimsmets#view=detail&group=time&jump=ga_yearmonth

And here's what looks like the standard way of changing horizontal axis date formats, but it doesn't seem to work in this case:

https://developers.google.com/chart/interactive/docs/reference#dateformatter

How do I convert "201411" to "November 2014" using Google Charts?


Solution

  • 201411 is a string, and formatDate is for dates, so you would need to convert it to date first to be able to use use dateFormatter formatType option.