JSON Structure Description
Have you ever wondered what is happening in the complex code of a connector? Read more to crack this shell open.
Last updated
Have you ever wondered what is happening in the complex code of a connector? Read more to crack this shell open.
Last updated
Let's split the JSON into three parts to understand the logic from beginning to the end. We won't describe every given parameter as some of the parameters are more important to us than to you. If you want to customise your queries by yourself than you should read and understand this.
Every template starts with defining the query:
naming and scheduling the connector
what the connector does and where the data will be stored (outputCode and Storage)
and other parameters, that are less important for you and more important to us
The magic starts to happen from the second part of the code, because the source, dimensions and metrics of the query are defined here.
The source is defining what platform the query will target.
Parameters specify exactly what dimensions and metrics will be downloaded. In this case, there is the: Date, Source/Medium, Campaign and Ad Group dimensions and from metrics there are: Sessions, Hits, Entrances, Bounces, Pageviews, Users, New Users, Conversions and Conversion Value.
In other words, you are listing which metrics from the API's platform you want to download.
Note: The structure must follow the naming conventions of the platform.
The third part of the query is very dependent on the second. In the second you specified what you want to download from API, but in the third, you need to define what will ROIVENUE do with the data and how it will manage it.
You can imagine this step as building columns in an Excel file. See this example:
You can see the repetitive structure of every column. Look at one of the most typical metrics from Google Analytics (sessions)a below.
With code you are telling the JSON to create a column with the name sessions.
The datatype is what kind of data are you storing in the cells. Long is a value, that tells the JSON to store integers in it.
The conceptType is saying if the field is metric or dimension.
SemanticType tells you how and in which format the field should be threaded.
The source parameter is referring to the source parameter from the second part of the query. The connector checks if the value in the source field refers to the same field from the second part and if yes, it populates the column with that data.
Note: You need to refer to the source parameter without the "ga:" prefix. Otherwise, the connector would fail.
Now you should be able to understand the logic of your JSON queries. The skeleton of every JSON stays the same, but the parameters can vary from platform to platform.
We currently provide tutorials for adjusting JSON in templates to these platforms: