The first step is to define a connection to your Google Analytics profile.
To define the connection we need the
website profile id.
Each website that you track within your google analytics is given a profile. All the connection information is stored in a file on the server and password is encrypted.
You can defined as many connections you need for each website profile and other Google analytics account.
With this approach, if you are managing multiple client Google analytics you can easily setup connections for them. Once you define connections all the queries are run against the
connection handle that is defined here.
Profile ID : You can find the profile ID within your Google Analytics account
How to find your Google Analytics Profile ID
Login to your Google Analytics
Select the website you wish to track
Click on the "Admin" tab
Click on "Profile Settings"
Copy the "Profile ID" (e.g 231206 for infocaptor.com)
Fill up the connection form and submit
Click on "Add new Connection Entry"
Once added you can proceed to execute queries against your profile.
Drag a square from left panel to center (any icon can be used)
2. Right click on the box and select "Data Source"
3. Select the infocaptor google analytics connection we just created
4. In the parameters copy/paste the following code (if not prepopulated or you are changing the parameters from other connection or service)
5. Once you click "OK", it sends out a query to Google Analytics API and in few seconds displays the number in the widget
We will try to understand what this number represents in the following section. We have given numbers to each parameter.
1. dimesnions: This parameter takes an array of dimension values. In the example above it provides one dimension i.e "source"
2. metrics : This takes an array of metric values. In the example it provides one metric i.e. "visits"
3. sort_metric : You can sort the results ascending or descending. If there is a negative sign in front of the metric value then it does a descending sort.
4. start_date: This is a very powerful parameter and requires a detailed explanation as follows
The date is required in the format of "Year-Mth-Day" e.g "2012-03-20"
And the parameter is an array with three components.
If you want to use a hard coded date value then just provide one value in the array
Using a hard coded value is good for testing purpose or doing historical reporting. But if you want to define a dashboard and want to use it everyday or month then changing the dates is not a good user experience.
So the date provides a variable format.
When you specify 3 inputs in the date array then it automatically assumes it is a variable date.
Allowed values for Date boundary (D1)
fdm : first day of month
ldm : last day of month
fdw : first day of week
ldw : last day of week
fdy : first day of year
ldy : last day of year
fdq : first day of quarter
ldq : last day of quarter
today : today's current date
Allowed values for Modifier Unit (D3)
d = day
m = month
Allowed values for Modifier Qty (D2)
Any positive or negative integer
With this variable format dates, you can define the dashboard once and configure it to show daily, weekly, quarterly, monthly or yearly aggregates.
6. filter: Using the filter you can pass extra conditions to the query
"filter" : "country == United States && visitorType == New Visitor"
"filter" : "country == United States && visitorType == New Visitor && browser == Firefox"
a moment but before that we will try to replace the shape of the icon
First select the icon object on the canvas (it will be surrounded by a blue border) and then right click on any icon on the left. This will replace the icon in the canvas leaving the data as it is.
This can be repeated any number of times with any icon. This works with only icons. For other widgets, you would need to copy the parameters and paste it in the widgets Data source.
By default the PHP API returns the first 30 results. You can increase the same by changing the max_rows parameter. Google Analytics returns a maximum of 10,000 results, even if you set the max_rows parameter above 10,000. To get the results above that limit you need to set the start_index parameter to 10,000, which will then get the results starting at 10,000.
8. max_rows: see start_index (#7)
9. show_totals_only: When we set the value to "Y" then it will return the total value only. If we change it to "N" it will show a listing of all the source and visit counts
Since it is going to show a listing, we choose a table grid to display the results.
10. number_scale_divider: This parameter will let you scale the metric value sent by Google Analytics. In the example below, the original value is 19,997 visits but when we change the number_scale_divider to 1000, it divides the number by 1000 and rounds it up.
This covers the basic usage of Google Analytics reporting.
For More advanced usage please refer to the documentation below