Statcounter API Documentation - Version 3
-
1. Introduction #
The Statcounter API accepts requests via the HTTP GET method. Results are returned in either JSON (default) or XML format. To perform the required task, simply send the necessary HTTP request, as described in this specification.
All API calls return an error response in the case of a failure. The structure of an error response (JSON format) is as follows:
{ "@attributes": { "status": "fail", }, "error": [{ "code": "CODE", "description": "ERROR_DESCRIPTION" }] } -
2. API Login Credentials #
To use the Statcounter API, you will require a Statcounter account with a paid upgrade. If you do not already have an account, you must sign up for an account. Paid upgrades are available here.
Once you have a Statcounter account with a paid upgrade, you will need to set your API password. You may then construct an API call.
If you do not have an upgraded account, you may test the Statcounter API using our Demo API User details:
Username: demo_user
API Password: statcounter
Demo Project ID: 2292634 -
3. Constructing an API Call #
Each Statcounter API call contains settings that configure the task or function that you wish to execute. To perform the required task, you must configure the correct settings.
As an example, we will look in detail at how to retrieve statistics for Recent Visitors.
All API calls are sent via HTTP to the same URL, so every API call must begin with:
http://api.statcounter.com/The correct function must then be added to the call (e.g. stats/, add_project/, update_project/, etc.). In this example, we will add "stats/", as stated in the specification for Recent Visitors:
http://api.statcounter.com/stats/The next step is to add the required settings, beginning with the "?" symbol, with each setting separated by the "&" symbol.
The "Version Number" (vn) setting determines the particular API version number that you wish to use. The current API version is version 3. To request the most recent API version number, we use "vn=3":
http://api.statcounter.com/stats/?vn=3Again, using Recent Visitors as an example, we will look at the "Stats" (s) setting. "Stats" determines the set of statistics which you wish to return e.g. summary, visitor, popular. To request the "Recent Visitor Activity" statistics, we use "s=visitor":
http://api.statcounter.com/stats/?vn=3&s=visitorThe "Format" (f) setting determines the format in which you wish to return data from the server. The available options are "JSON" and "XML". The default setting is "JSON". To request "XML" format, use "f=xml":
http://api.statcounter.com/stats/?vn=3&s=visitor&f=xmlThe "Project ID" (pi) is always required when retrieving data for a particular project. To request project ID "1234567", for example, use "pi=1234567":
http://api.statcounter.com/stats/?vn=3&s=visitor&f=xml&pi=1234567You can also set the number of results (n) that you wish to return. This setting is optional, and will return 20 results by default if not set. To request 10 returned results, use "n=10":
http://api.statcounter.com/stats/?vn=3&s=visitor&f=xml&pi=1234567&n=10For security and authentication reasons, each API call must be accompanied by the time of execution (t) of the call, in Unix timestamp format. When a scripting language such as PHP, the timestamp can easily be generated with the "time()" function e.g. timestamp "1329142078". To include this timestamp in your API call, we use "t=1329142078":
http://api.statcounter.com/stats/?vn=3&s=visitor&f=xml&pi=1234567&n=10&t=1329142078You must also include your Statcounter username in the API call e.g. username "myusername". To include your username in the API call, we use "u=myusername":
http://api.statcounter.com/stats/?vn=3&s=visitor&f=xml&pi=1234567&n=10&t=1329142078&u=myusernameThe final step in creating your API call for Recent Visitors is to add the SHA-1 (sha1) authentication data. The SHA-1 proves your identity within the Statcounter system. The SHA-1 value that you must use is found by calculating the SHA-1 value of the existing URL query string to-date, with your API password appended.
In our example, the URL query string to-date is:
?vn=3&s=visitor&f=xml&pi=1234567&n=10&t=1329142078&u=myusernameIf we take our example password to be "mypassword", and append it to the URL query string, we get the following string:
?vn=3&s=visitor&f=xml&pi=1234567&n=10&t=1329142078&u=myusernamemypasswordUsing PHP, the SHA-1 of this string can easily be found using the sha1() function:
sha1("?vn=3&s=visitor&f=xml&pi=1234567&n=10&t=1329142078&u=myusernamemypassword");The following SHA-1 string is returned:
e0fd149f1999f81ce474070a01c7b14c01e4044fThe final step in creating our API call is to go back to our URL string to-date, and add the SHA-1 value:
http://api.statcounter.com/stats/?vn=3&s=visitor&f=xml&pi=1234567&n=10&t=1329142078&u=myusername&sha1=e0fd149f1999f81ce474070a01c7b14c01e4044fWhen this URL is passed to the Statcounter server via HTTP, the data will be returned, in this case, in XML format. The URL will only work for 15 minutes, after which time, it will need to be re-constructed.
-
4. Retrieve Stats #
-
4.1 Date Range Selection #
The Statcounter API allows for the retrieval of each statistic type (Popular Pages, Recent Visitors, etc.) within a set time period. To select your required period, just add the necessary details to your API call, as detailed for each appropriate time period below. If no time period is specified, the API will search all available records.
Hourly:
&g=hourly&sh=START_HOUR&sd=START_DAY&sm=START_MONTH&sy=START_YEAR&eh=END_HOUR&ed=END_DAY&em=END_MONTH&ey=END_YEARDaily:
Weekly:
Monthly:
Quarterly:
Yearly:
&g=yearly&sy=START_YEAR&ey=END_YEARWith the exception of Summary Stats, the returned response structure for each statistic type is unchanged, regardless as to whether a time period is specified or not. Specific examples are given for Summary Stats (below) due to different response structures.
-
4.2 Multiple Project Selection #
The Statcounter API allows for the retrieval of stats data for multiple projects in one call. This may be faster than making a seperate call to the stats function for each project of interest. To request data for multiple projects, just add multiple "Project ID" (pi) parameters to your stats call:
http://api.statcounter.com/stats/?vn=3&s=visitor&f=xml&pi=123&pi=456pi=789The returned response structure is different when multiple "Project ID" (pi) parameters are used. The response will consist of an array of objects composed of a id attribute, representing the Project ID, and the normal sc_data attribute with the associated project's stats data:
{ "@attributes": { "status": "ok", }, "project": [{ "id": "123", "sc_data": [{ ... }, { "id": "456", "sc_data": [{ ... }, { "id": "789", "sc_data": [{ ... }] }] }-
4.3 Summary Stats #
-
4.3.1 Summary Stats - Hourly #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=summary&g=GRANULARITY&sh=START_HOUR&sd=START_DAY&sm=START_MONTH&sy=START_YEAR&eh=END_HOUR&ed=END_DAY&em=END_MONTH&ey=END_YEAR&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "date": "DATE", (YYYY-MM-DD) "hour": "HOUR", (HH) "page_views": "PAGE_VIEWS", "unique_visits": "UNIQUE_VISITS", "returning_visits": "RETURNING_VISITS", "first_time_visits": "FIRST_TIME_VISITS" }] }Here is a sample return containing data from a number of days:
{ "@attributes":{ "status":"ok" }, "sc_data": [{ "date":"2012-01-10", "hour":"01", "page_views":"3369", "unique_visits":"938", "returning_visits":"289" }, { "date":"2012-01-11", "hour":"02", "page_views":"2409", "unique_visits":"840", "returning_visits":"258" }, { "date":"2012-01-12", "hour":"03", "page_views":"2712", "unique_visits":"1068", "returning_visits":"277" }] }
-
4.3.2 Summary Stats - Daily #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=summary&g=GRANULARITY&sd=START_DAY&sm=START_MONTH&sy=START_YEAR&ed=END_DAY&em=END_MONTH&ey=END_YEAR&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: New methodology session & visitor summary data
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "date": "DATE", (YYYY-MM-DD) "page_views": "PAGE_VIEWS", "unique_visits": "UNIQUE_VISITS", "returning_visits": "RETURNING_VISITS", "first_time_visits": "FIRST_TIME_VISITS" }] }Here is a sample return containing data from a number of days:
{ "@attributes":{ "status":"ok" }, "sc_data": [{ "date":"2012-01-10", "page_views":"3369", "unique_visits":"938", "returning_visits":"289" }, { "date":"2012-01-11", "page_views":"2409", "unique_visits":"840", "returning_visits":"258" }, { "date":"2012-01-12", "page_views":"2712", "unique_visits":"1068", "returning_visits":"277" }] }
-
4.3.3 Summary Stats - Weekly #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=summary&g=GRANULARITY&sy=START_YEAR&sw=START_WEEK&ey=END_YEAR&ew=END_WEEK&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: New methodology session & visitor summary data
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "year": "YEAR", "week": "WEEK", "page_views": "PAGE_VIEWS", "unique_visits": "UNIQUE_VISITS", "returning_visits": "RETURNING_VISITS", "first_time_visits": "FIRST_TIME_VISITS" }] }Here is a sample return containing data from a number of days:
{ "@attributes":{ "status":"ok" }, "sc_data": [{ "year":"2012", "week":"1", "page_views":"3369", "unique_visits":"938", "returning_visits":"289" }, { "year":"2012", "week":"2", "page_views":"2409", "unique_visits":"840", "returning_visits":"258" }] }
-
4.3.4 Summary Stats - Monthly #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=summary&g=GRANULARITY&sm=START_MONTH&sy=START_YEAR&em=END_MONTH&ey=END_YEAR&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: New methodology session & visitor summary data
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "year": "YEAR", "month": "MONTH", (MM) "page_views": "PAGE_VIEWS", "unique_visits": "UNIQUE_VISITS", "returning_visits": "RETURNING_VISITS", "first_time_visits": "FIRST_TIME_VISITS" }] }Here is a sample return containing data from a number of days:
{ "@attributes":{ "status":"ok" }, "sc_data": [{ "year":"2012", "month":"1", "page_views":"3369", "unique_visits":"938", "returning_visits":"289" }, { "year":"2012", "month":"2", "page_views":"2409", "unique_visits":"840", "returning_visits":"258" }, { "year":"2012", "month":"3", "page_views":"2712", "unique_visits":"1068", "returning_visits":"277" }] }
-
4.3.5 Summary Stats - Quarterly #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=summary&g=GRANULARITY&sy=START_YEAR&sq=START_QUARTER&ey=END_YEAR&eq=END_QUARTER&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: New methodology session & visitor summary data
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "year": "YEAR", "quarter": "QUARTER", "page_views": "PAGE_VIEWS", "unique_visits": "UNIQUE_VISITS", "returning_visits": "RETURNING_VISITS", "first_time_visits": "FIRST_TIME_VISITS" }] }Here is a sample return containing data from a number of days:
{ "@attributes":{ "status":"ok" }, "sc_data": [{ "year":"2012", "quarter": "1", "page_views":"3369", "unique_visits":"938", "returning_visits":"289" }, { "year":"2012", "quarter": "2", "unique_visits":"840", "returning_visits":"258" }] }
-
4.3.6 Summary Stats - Yearly #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=summary&g=GRANULARITY&sy=START_YEAR&ey=END_YEAR&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: New methodology session & visitor summary data
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "year": "YEAR", "page_views": "PAGE_VIEWS", "unique_visits": "UNIQUE_VISITS", "returning_visits": "RETURNING_VISITS", "first_time_visits": "FIRST_TIME_VISITS" }] }Here is a sample return containing data from a number of days:
{ "@attributes":{ "status":"ok" }, "sc_data": [{ "year":"2012", "page_views":"3369", "unique_visits":"938", "returning_visits":"289" }] }
-
-
4.4 Recent Visitors #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=visitor&pi=PROJECT_ID&n=NUMBER_OF_RESULTS&t=TIME_OF_EXECUTION&f=FORMAT&u=USERNAME&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Optional: Filter SelectionSuccessful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "log_visits": "The number of visits from this visitor available in the log.", "entries_in_visit": "The number of page views in the most recent visit from a visitor.", "entry_t": "ENTRY_TIME", "entry_url": "ENTRY_PAGE_URL", "entry_title": "ENTRY_PAGE_TITLE", "se_keywords": " SEARCH_ENGINE_KEYWORDS", "link": "REFERRAL_URL", "country_name": "COUNTRY_NAME", "state": "STATE", "res": "RESOLUTION", "exit_t": "EXIT_TIME", "exit_url": "EXIT_PAGE_URL", "exit_title": "EXIT PAGE TITLE", "returning_count": "The number of returning visits from this visitor based on the cookie data (not limited to log size).", "browser_name": "BROWSER_NAME", "browser_version": "BROWSER_VERSION", "os": "OS", "width": "WIDTH", "height": "HEIGHT", "javascript": "JAVASCRIPT", "country": "COUNTRY", "city": "CITY", "isp": "ISP", "ip_address": "IP_ADDRESS", "ip_label": "IP_LABEL", "visitor_uuid": "VISITOR UUID", "latitude": "LATITUDE", "longitude": "LONGITUDE", "num_entry": "The total number of page views for this visitor available in the log.", "visit_length": "VISIT_LENGTH" }] } -
4.5 Popular Pages #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=popular&pi=PROJECT_ID&n=NUMBER_OF_RESULTS&c=CHOP_URL&ct=COUNT_TYPE&t=TIME_OF_EXECUTION&f=FORMAT&u=USERNAME&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "page_views": "PAGE_VIEWS", "title": "TITLE", "url": "URL" }] } -
4.6 Entry Pages #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=entry&pi=PROJECT_ID&n=NUMBER_OF_RESULTS&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "page_views": "PAGE_VIEWS", "page_title": "PAGE_TITLE", "page_url": "PAGE_URL" }] } -
4.7 Exit Pages #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=exit&pi=PROJECT_ID&n=NUMBER_OF_RESULTS&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "page_views": "PAGE_VIEWS", "title": "PAGE_TITLE", "page_url": "PAGE_URL" }] } -
4.8 Came From #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=camefrom&pi=PROJECT_ID&n=NUMBER_OF_RESULTS&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&e=EXTERNAL&ese=EXCLUDE_SEARCH_ENGINES&gbd=GROUP_BY_DOMAIN&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "page_views": "PAGE_VIEWS", "referring_url": "REFERRING_URL" }] } -
4.9 Recent Came From #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=recent_camefrom&pi=PROJECT_ID&n=NUMBER_OF_RESULTS&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&ese=EXCLUDE_SEARCH_ENGINES&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "referring_url": "REFERRING_URL", "time": "TIME", "entry_page": "ENTRY_PAGE", "ip_address": "IP_ADDRESS", "ip_label": "IP_LABEL", "visitor_uuid": "VISITOR UUID", "se_keywords": "SE_KEYWORDS" }] } -
4.10 Recent Keyword Activity #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=keyword-activity&pi=PROJECT_ID&eek=EXCLUDE_ENCRYPTED_KEYWORDS&n=NUMBER_OF_RESULTS&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&e=EXTERNAL&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "search_engine_name": "SEARCH_ENGINE_NAME", "search_engine_host": "SEARCH_ENGINE_HOST", "keyword": "KEYWORD", "time": "TIME", "page_url": "PAGE_URL", "page_title": "PAGE_TITLE", "referring_url": "REFERRING_URL", "ip_address": "IP_ADDRESS", "ip_label": "IP_LABEL", "visitor_uuid": "VISITOR UUID" }] } -
4.11 Browsers #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=browsers&de=DEVICE&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "page_views": "PAGE_VIEWS", "browser_name": "BROWSER_NAME", "browser_version": "BROWSER_VERSION", "percentage": "PERCENTAGE" }] } -
4.12 Operating Systems #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=os&de=DEVICE&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "page_views": "PAGE_VIEWS", "os_name": "OS_NAME", "percentage": "PERCENTAGE" }] } -
4.13 Search Engines #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=search_engine&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "page_views": "PAGE_VIEWS", "search_engine_name": "SEARCH_ENGINE_NAME", "search_engine_provider": "SEARCH_ENGINE_PROVIDER", "percentage": "PERCENTAGE" }] } -
4.14 Country #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=country&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "page_views": "PAGE_VIEWS", "country_name": "COUNTRY_NAME", "percentage": "PERCENTAGE" }] } -
4.15 City #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=city&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "page_views": "PAGE_VIEWS", "city_name": "CITY_NAME", "percentage": "PERCENTAGE" }] } -
4.16 Region #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=region&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "page_views": "PAGE_VIEWS", "region_name":"REGION_NAME", "percentage": "PERCENTAGE" }] } -
4.17 ISP #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=isp&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "page_views": "PAGE_VIEWS", "isp_vendor": "ISP_VENDOR", "percentage": "PERCENTAGE" }] } -
4.18 Recent Pageload Activity #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=pageload&de=DEVICE&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Optional: Filter SelectionSuccessful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "page_url": "PAGE_URL", "time": "TIME", "referring_url": "REFERRING_URL", "page_title": "PAGE_TITLE", "browser_name": "BROWSER_NAME", "browser_version": "BROWSER_VERSION", "os_name": "OS_NAME", "device_vendor": "DEVICE_VENDOR", "device_model": "DEVICE_MODEL", "se_keywords": "SEARCH_ENGINE_KEYWORDS", "resolution_width": "RESOLUTION_WIDTH", "resolution_height": "RESOLUTION_HEIGHT", "isp": "ISP", "city": "CITY", "state": "STATE", "country": "COUNTRY", "ip_address": "IP_ADDRESS", "ip_label": "IP_LABEL", "visitor_uuid": "VISITOR UUID" }] } -
4.19 Exit Links #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=exit-links&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "hit": "HIT", "link": "EXIT_LINK" }] } -
4.20 Exit Link Activity #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=exit-link-activity&de=DEVICE&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "link": "EXIT_LINK", "time": "TIME", "page_url": "EXIT_PAGE_URL", "page_title": "EXIT_PAGE_TITLE", "ip_address": "IP_ADDRESS", "ip_label": "IP_LABEL", "visitor_uuid": "VISITOR UUID" }] } -
4.21 Downloads #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=downloads&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "hit": "HIT", "link": "DOWNLOAD_LINK" }] } -
4.22 Download Link Activity #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=download-link-activity&de=DEVICE&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "link": "DOWNLOAD_LINK", "time": "TIME", "page_url": "DOWNLOAD_PAGE_URL", "page_title": "DOWNLOAD_PAGE_TITLE", "ip_address": "IP_ADDRESS", "ip_label": "IP_LABEL", "extension": "EXTENSION", "visitor_uuid": "VISITOR UUID" }] } -
4.23 Session Length #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=visit_length&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "Lessthan5secs": "STRING", "From5secsto30secs": "STRING", "From30secsto5mins": "STRING", "From5minsto20mins": "STRING", "From20minstoanhour": "STRING", "Longerthananhour": "STRING" }] } -
4.24 Returning Visits #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=returning_visits&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "ReturningVisitsFirstTimeVisitors": "STRING", "ReturningVisits1to5": "STRING", "ReturningVisits6to10": "STRING", "ReturningVisits10OrMore": "STRING" }] } -
4.25 Keyword Analysis #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=keyword_analysis&pi=PROJECT_ID&ck=COMBINE_KEYWORDS&eek=EXCLUDE_ENCRYPTED_KEYWORDS&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "keyword_count": "KEYWORD_COUNT", "keyword": "KEYWORD", "percentage": "PERCENTAGE", "search_engine_name": "SEARCH_ENGINE_NAME", "search_engine_host": "SEARCH_ENGINE_HOST" }] } -
4.26 Lookup Visitor Navigation Path #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=lookup_visitor_navigation&ip=IP_ADDRESS&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "url": "URL", "referring_url": "REFERRING_URL" "type": "TYPE", "time": "TIME" }] } -
4.27 Lookup Visitor Info #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=lookup_visitor_info&ip=IP_ADDRESS&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "resolution": "RESOLUTION", "country_name": "COUNTRY_NAME", "city": "CITY", "state": "STATE", "isp": "ISP", "browser_name": "BROWSER_NAME", "os": "OS", "host": "HOST", "latitude": "LATITUDE", "longitude": "LONGITUDE", "javascript": "JAVASCRIPT", "visit_length": "VISIT_LENGTH", "returning_visits": "RETURNING_VISITS", "ip_label": "IP_LABEL" }] } -
4.28 Mobile Devices #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=mobile_device&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "hit": "HIT", "vendor": "VENDOR", "device": "DEVICE", "percentage": "PERCENTAGE", }] } -
4.29 Platform #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=platform&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "desktop": "DESKTOP", "mobile": "MOBILE", "tablet": "TABLET", "console": "CONSOLE" }] } -
4.30 Export #
Note: This function is designed to give API access to the same data provided by the Download Log feature on the Statcounter website.
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=export&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYOptional: Date Range Selection
Successful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "t":"DATETIME", "ip":"IP", "ip_label":"IP_LABEL", "browser_name":"BROWSER_NAME", "browser_version":"BROWSER_VERSION", "os":"OS", "resolution":"RESOLUTION", "country":"COUNTRY", "region":"REGION", "city":"CITY", "postal_code":"POSTAL_CODE", "isp":"ISP", "returning_count":"RETURNING_COUNT", "type":"TYPE", "url":"URL", "title":"TITLE", "link":"LINK", "se_host":"SE_HOST", "se_name":"SE_NAME", "se_keywords":"SE_KEYWORDS", "is_paid":"IS_PAID" }] } -
4.31 Incoming Traffic #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=incoming&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes": { "status": "ok" }, "sc_data": [{ "direct_traffic": "Direct traffic", "direct_traffic_percentage": "Direct traffic percentage", "search_engine_referrals": "Search engine referrals", "search_engine_referrals_percentage": "Search engine referrals percentage", "referring_websites": "Referring websites", "referring_websites_percentage": "Referring websites percentage" }] } -
4.32 Language #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=language&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes": { "status": "ok" }, "sc_data": [{ "language": "en-ie", "num": "213", "percentage": "100.00%", "perc": "1" }] } -
4.33 Bounces #
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=bounces&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes": { "status": "ok" }, "sc_data": [{ "url": "PAGE_URL", "visits": "VISITS_COUNT", "bounce_rate": "BOUNCE_RATE_PERCENTAGE", "bounces":"BOUNCE_COUNT"}] }
-
-
Query String Fields
Each API call is made with a URL containing a detailed query string. The fields used by the API are detailed below.
vn – Version Number
The version number of the Statcounter API that you are calling. This document describes the Statcounter API for Version 3 so the value '3' should always be passed.
Example: vn=3f – Format
The required format of the returned data. The available options are 'json' and 'xml'. JSON is the default format.
Example: f=xmls – Stats
The stats that you wish to call. The available options are:
- summary (Summary Stats)
- visitor (Recent Visitor Activity)
- popular (Popular Pages)
- entry (Entry Pages)
- exit (Exit Pages)
- camefrom (Recent Came From)
Example: s=popularpi – Project ID
The project ID of your Statcounter project.
Example: pi=7407742u – Username
Your statCounter username.
Example: u=myusernamewt – Website Title
The name that will be given to the new Statcounter project e.g. 'My Website'. The title must be encoded for use in the URL.
Example: wt=My%20Websitewu – Website URL
The URL of the website e.g. 'http://www.mywebsite.com/'. The URL must be encoded for use in the URL.
Example: wu=http%3A%2F%2Fwww.mywebsite.comls – Log Size
The desired log size for the project.
Example: ls=5000t – Time of Execution
The time of execution of the request, in Unix timestamp format.
Example: t=1321438882tz – Time Zone
The time zone to be used for the project stats e.g. 'America/New_York'. See Time Zone Options in the Appendix for the complete list. The default is America/New_York. The Time Zone must be encoded for use in the URL.
Example: tz=America%2FNew_Yorkps – Public Stats
Set the level of public access to stats in a project. The default is that all stats are publicly available. The available options are:
0: All public stats are disabled 1: All stats are public 2: Only 'Summary Stats' are public Example: ps=2n – Number of Results
The number of results to return.
Example: n=10c – Chop URL
Chop the query string from the returned URL. Many URLs contain data variables in a query string that is used to set details on the web page. Chopping the query string can make the returned URL list easier to read and less cluttered. The available options are '0' and '1'. The default is '1' (chop URL).
Example: c=1ct – Count Type
The type of counts used by a stat. A stat can be counted by page views or visitors. The available api options are 'page_view' and 'visitor'. The default is 'page_view'.
Example: ct=page_viewg – Granularity
The time interval of returned stats, used with a 'Summary Stats' query. Default value is 'weekly'. The available options are:
- hourly
- daily
- weekly
- monthly
- quarterly
- yearly
Example: g=weeklysh – Start Hour
The start hour for a time period in a 'Summary Stats' query. Default value is '0'.
Example: sh=10sd – Start Day
The start day for a time period in a 'Summary Stats' query. Default value is '1'.
Example: sd=26sm – Start Month
The start month for a time period in a 'Summary Stats' query. Default value is '1'.
Example: sm=8sy – Start Year
The start year for a time period in a 'Summary Stats' query. Default value is '2024'.
Example: sy=2011sw – Start Week
The start week for a time period in a 'Summary Stats' query. Only required if granularity is 'weekly'. Default value is '1'.
Example: sw=2sq – Start Quarter
The start quarter for a time period in a 'Summary Stats' query. Only required if granularity is 'quarterly'. Default value is '1'.
Example: sq=1eh – End Hour
The end hour for a time period in a 'Summary Stats' query. Default value is '23'.
Example: eh=22ed – End Day
The end day for a time period in a 'Summary Stats' query. Default value is '28'.
Example: ed=30em – End Month
The end month for a time period in a 'Summary Stats' query. Default value is '12'.
Example: em=11ey – End Year
The end year for a time period in a 'Summary Stats' query. Default value is '2024'.
Example: ey=2012ew – End Week
The end week for a time period in a 'Summary Stats' query. Only required if granularity is 'weekly'. Default value is '2'.
Example: ew=34eq – End Quarter
The end quarter for a time period in a 'Summary Stats' query. Only required if granularity is 'quarterly'. Default value is '4'.
Example: eq=4e – Exclude External
Choose to exclude external results to your site. Available options are '0' or '1'. Default value is '1' (exclude external).
Example: e=1ese – Exclude Search Engines
Choose to exclude search engine driven results to your site. Available options are '0' or '1'. Default value is '0' (include search engines).
Example: ese=1eek – Exclude Encrypted Keywords
Choose to exclude encrypted keyword results. Available options are '0' or '1'. Default value is '0' (include encrypted keyword results).
Example: eek=1ck – Combine Keywords
Choose to combine keyword results based on one of three possible criteria. Available options are 'search_engine_host' or 'search_engine_name' or 'together'. Default value is 'search_engine_host'.
Example: ck=togethergbd – Group By Domain
Choose to group results by referring domain, in the 'Came From' stats query. Available options are '0' or '1'. Default value is '0' (do not group by domain).
Example: gbd=1de – Device
Choose the device type. Default value is 'All'. The available options are:
- all
- desktop
- mobile
Example: de=mobileip – I.P. Address
The I.P. address of a visitor you want to look up, in the stat lookup_visitor.
Example: ip=192.168.1.1Only available when adding a new project or updating a pre-existing one:
gid – Project Group ID
The Group ID reference where you want assign project.
Example: gid=12gn – Project Group Name
The Group name where you want assign project.
Example: gn=social-projectsfcg – Force to create Project Group
In case you want to assign a project to a nonexistent group: you can combine `fcg=1` with the parameter `&gn=[PROJECT_GROUP_NAME]` and create the group then the api call will assign it to the project in the api call
Example: &fcg=1&gn=social-projects
NOTE: This parameter is available when you are creating or updating a project only. Will be ignored if parameter `&gid` is present on the api call.sha1 – SHA-1 Proof
The SHA-1 proof is used to verify your identity within the Statcounter system. It is created from the SHA-1 value of the existing URL query string to-date, with your API password appended. e.g. sha1 (query string + api password)- Query string is the full URL query string, beginning with and including '?'.
- The API password is set by you (see API Login Credentials for more details).
-
5. Filter Selection #
For certain stats (currently 'Recent Visitors' and 'Recent Pageload Activity'), it is possible to filter the results to only return those with a certain URL Paths and/or Page Titles.
NOTE! We recommend not using both types of filter at the same time.
-
5.1 Page Match: #
When using Page Match, 'cart' would return all pages whose Page Title or url-path match, e.g. both pages with 'cart' or 'cartoon' would be returned.If you searched for '%2Fcart' instead only the url-paths would be returned.
NOTE! The character "/" converts to "%2F" when URL Encoded.&page_match=URL_ENCODED_STRING -
5.2 Domain Path:
When using Domain Path it is necessary to include the 'host' part of the url, and only url matched are returned e.g. 'mywebsite.com%2Fcart'. This is of particular use when searching for a root page, e.g. 'mywebsite.com%2F'.
NOTE! The character "/" converts to "%2F" when URL Encoded.&domainpath=URL_ENCODED_STRING -
URL Encoded String
URL Encoding converts characters into a format that can be transmitted over the Internet. Any characters outside the ASCII character-set is converted to valid ASCII format consisting of a "%" followed by two hexadecimal digits.
Example: "mywebsite.com/" would be converted to:
mywebsite.com%2F
For additional call-structure and successful response structure (JSON format) please see: Recent Visitors or Recent Pageload Activity.
-
-
6. Create a New Project #
http://api.statcounter.com/add_project/?vn=VERSION_NUMBER&wt=WEBSITE_TITLE&wu=WEBSITE_URL&t=TIME_OF_EXECUTION&u=USERNAME&tz=TIME_ZONE&ps=PUBLIC_STATS&f=FORMAT&u=USERNAME&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes": { "status": "ok", }, "sc_data": [{ "project_id": "PROJECT_ID", "security_code": "SECURITY_CODE" }] }Once you receive a successful response, it is important to save the PROJECT_ID and the SECURITY_CODE into a database for that website, as these values will need to be retrieved each time the website is loaded.
Additional documentation: Creating a new project within a group
-
7. Update Project Settings #
http://api.statcounter.com/update_project/?vn=VERSION_NUMBER&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&ps=PUBLIC_STATS&f=FORMAT&u=USERNAME&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes": { "status": "ok" } }Additional documentation: Assigning an existing project to a group
-
8. Increase Project Log Size #
This call allows you to increase the log size of any of your projects. The log size must be greater than 500, and you cannot use this call to decrease the log size.
http://api.statcounter.com/update_logsize/?vn=VERSION_NUMBER&pi=PROJECT_ID&ls=LOG_SIZE&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes": { "message": "The adjust log request has been received for project ID PROJECT_ID and will be processed in the next 5 minutes" } } -
9. Retrieve Account Log Sizes #
This call will return log details for each project associated with your account.
http://api.statcounter.com/account_logsizes/?vn=VERSION_NUMBER&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes": { "status":"ok" }, "sc_data": { "project_id":"PROJECT_ID", "project_name":"PROJECT_NAME", "log_size":"LOG_SIZE", "log_usage":"LOG_USAGE", "log_size_days_estimated":"LOG_SIZE_DAYS_ESTIMATE", "log_size_days_usage":"LOG_SIZE_DAYS_USAGE" } } -
10. Retrieve User Details #
This call will return details of the user making the call.
http://api.statcounter.com/user_details/?vn=VERSION_NUMBER&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes": { "status":"ok" }, "sc_data":[{ "name":"FULL_NAME", "email":"EMAIL_ADDRESS", "log_quota":"LOG_QUOTA", "upgraded":"UPGRADED", "date_format":"DATE_FORMAT", "time_format":"TIME_FORMAT", "timezone":"TIMEZONE" }] }Note:
date_format key:
- DD MONTH YYYY
- MONTH DD YYYY
- YYYY.MM.DD
- DDth MONTH YYYY
- MONTH DDth YYYY
time_format key:
- HH:MM:SS
- HH:MM:SS AM/PM
- HH:MM:SS
- HH:MM:SS AM/PM
-
11. Integrate Statcounter Stats using an iframe #
To view the public website stats, the user needs to be sent to the following website URL:
http://statcounter.com/pPROJECT_ID?guest=1project_id
The project ID returned by Statcounter via the API.
Example: 3104569The user can view their website stats inside any control panel with the following iframe integration:
<HTML> <HEAD> <TITLE>User Admin Panel</TITLE> </HEAD> <BODY> <p>Your Standard Control Panel HTML here</p> <iframe src = "http://statcounter.com/pPROJECT_ID?guest=1" width="100%" height="900"> <p>Your browser does not support iframes.</p> </iframe> </BODY> </HTML> -
12. Retrieve User Project Details #
This call will return details of each project for which the given user has sufficient permissions.
http://api.statcounter.com/user_projects/?vn=VERSION_NUMBER&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes": { "status":"ok" }, "sc_data":[{ "project_id":"PROJECT_ID", "security_code":"SECURITY_CODE", "project_name":"PROJECT_NAME", "url":"URL", "sc_invisible":"SC_INVISIBLE", "project_group_id":"PROJECT_GROUP_ID", "project_group_name":"PROJECT_GROUP_NAME", "hidden_group":"HIDDEN_GROUP" }] } -
13. Select Project Details #
This call will return details of a project specified by the project id (pi) parameter
http://api.statcounter.com/select_project/?vn=VERSION_NUMBER&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes": { "status":"ok" }, "sc_data":[{ "project_name":"PROJECT_NAME", "log_size": "LOG_SIZE", "timezone": "TIME_ZONE", "url":"URL", "log_oldest_entry":"LOG_OLDEST_ENTRY", "log_latest_entry":"LOG_LATEST_ENTRY", "created_at":"CREATED_AT" }] } -
14. Create IP Label #
This call allows you to create an IP address label for any of your projects.
http://api.statcounter.com/create_ip_label?vn=VERSION_NUMBER&pi=PROJECT_ID&ip=IP_ADDRESS&ipl=IP_LABEL&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes": { "status":"ok" } } -
15. Get IP Labels #
This call allows you to get all IP address labels for any of your projects.
http://api.statcounter.com/get_ip_labels?vn=VERSION_NUMBER&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes": { "status":"ok" }, "sc_data":[{ "ip_address":"IP_ADDRESS", "ip_address_label": "IP_ADDRESS_LABEL" }] } -
16. Delete IP Label #
This call allows you to delete an IP address label for any of your projects.
http://api.statcounter.com/delete_ip_label?vn=VERSION_NUMBER&pi=PROJECT_ID&ipl=IP_LABEL&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes": { "status":"ok" } } -
17. Delete Project #
This call allows you to delete a project.
NOTE:
a. this API call will require an admin user and the admin password
b. this API call will delete all the users related to the project. If that the case an user it's related with other projects then won't be deleted.http://api.statcounter.com/remove_project?vn=VERSION_NUMBER&pi=PROJECT_ID&u=ADMIN_USERNAME&up=ADMIN_USER_PASSWORD&t=TIME_OF_EXECUTION&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes": { "status":"ok" } } -
18. Appendix: #
-
18.1 Add a Project to a Group #
This call is an example of adding a new project and assigning it to a Project Group in one call.
The additional parameters that are relevant here are "gn" - the group name - or "gid" - the group id - and "fcg", which instructs the call to create the project group with the passed name if it doesn't already exist. "gid" is only used where you know the id of an existing group - in all other cases it is ignored. In the example below we are using the group name (gn) and force create group (fcg) parameters together, but if you knew the id of an existing group, you could pass that instead in the group id (gid) parameter.
http://api.statcounter.com/add_project/?vn=VERSION_NUMBER&wt=WEBSITE_TITLE&wu=WEBSITE_URL&t=TIME_OF_EXECUTION&u=USERNAME&tz=TIME_ZONE&ps=PUBLIC_STATS&gn=GROUP_NAME&fcg=FORCE_CREATE_GROUP&f=FORMAT&u=USERNAME&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes":{ "status":"ok" }, "sc_data":[{ "project_id":"PROJECT_ID", "security_code":"SECURITY_CODE", "project_group_id":"PROJECT_GROUP_ID" }] }In a similar fashion you can use the `update-project` API call to assign an existing project to a project group. Again, you pass "gn" (group name) or "gi" (group id) - and indicate if the project group should be created if it doesnt already exist, via the paramter "fcg" (force create group). In the example below we are using a known group ID to indicate the group we want to assign the project to.
http://api.statcounter.com/update_project/?vn=VERSION_NUMBER&pi=PROJECT_ID&t=TIME_OF_EXECUTION&u=USERNAME&ps=PUBLIC_STATS&gid=GROUP_ID&f=FORMAT&u=USERNAME&sha1=SHA-1_TO_PROVE_IDENTITYSuccessful response structure (JSON format):
{ "@attributes":{ "status":"ok" }, "sc_data":[ { "project_id":"PROJECT_ID", "project_group_id":"PROJECT_GROUP_ID" } ] } -
18.2 Timezone parameter options:#
- Africa/Abidjan
- Africa/Accra
- Africa/Addis_Ababa
- Africa/Algiers
- Africa/Asmera
- Africa/Bamako
- Africa/Bangui
- Africa/Banjul
- Africa/Bissau
- Africa/Blantyre
- Africa/Brazzaville
- Africa/Bujumbura
- Africa/Cairo
- Africa/Casablanca
- Africa/Ceuta
- Africa/Conakry
- Africa/Dakar
- Africa/Dar_es_Salaam
- Africa/Djibouti
- Africa/Douala
- Africa/El_Aaiun
- Africa/Freetown
- Africa/Gaborone
- Africa/Johannesburg
- Africa/Kampala
- Africa/Khartoum
- Africa/Kigali
- Africa/Kinshasa
- Africa/Lagos
- Africa/Libreville
- Africa/Lome
- Africa/Luanda
- Africa/Lubumbashi
- Africa/Lusaka
- Africa/Malabo
- Africa/Maputo
- Africa/Maseru
- Africa/Mbabane
- Africa/Mogadishu
- Africa/Monrovia
- Africa/Nairobi
- Africa/Ndjamena
- Africa/Niamey
- Africa/Nouakchott
- Africa/Ouagadougou
- Africa/Porto-Novo
- Africa/Sao_Tome
- Africa/Timbuktu
- Africa/Tripoli
- Africa/Tunis
- Africa/Windhoek
- America/Adak
- America/Anchorage
- America/Anguilla
- America/Antigua
- America/Araguaina
- America/Aruba
- America/Asuncion
- America/Barbados
- America/Belem
- America/Belize
- America/Boa_Vista
- America/Bogota
- America/Boise
- America/Buenos_Aires
- America/Cambridge_Bay
- America/Cancun
- America/Caracas
- America/Catamarca
- America/Cayenne
- America/Cayman
- America/Chicago
- America/Chihuahua
- America/Cordoba
- America/Costa_Rica
- America/Cuiaba
- America/Curacao
- America/Dawson
- America/Dawson_Creek
- America/Denver
- America/Detroit
- America/Dominica
- America/Edmonton
- America/El_Salvador
- America/Ensenada
- America/Fortaleza
- America/Glace_Bay
- America/Godthab
- America/Goose_Bay
- America/Grand_Turk
- America/Grenada
- America/Guadeloupe
- America/Guatemala
- America/Guayaquil
- America/Guyana
- America/Halifax
- America/Havana
- America/Hermosillo
- America/Indiana/Knox
- America/Indiana/Marengo
- America/Indiana/Vevay
- America/Indianapolis
- America/Inuvik
- America/Iqaluit
- America/Jamaica
- America/Jujuy
- America/Juneau
- America/Kentucky/Monticello
- America/La_Paz
- America/Lima
- America/Los_Angeles
- America/Louisville
- America/Maceio
- America/Managua
- America/Manaus
- America/Martinique
- America/Mazatlan
- America/Mendoza
- America/Menominee
- America/Merida
- America/Mexico_City
- America/Miquelon
- America/Monterrey
- America/Montevideo
- America/Montreal
- America/Montserrat
- America/Nassau
- America/New_York
- America/Nipigon
- America/Nome
- America/Noronha
- America/Panama
- America/Pangnirtung
- America/Paramaribo
- America/Phoenix
- America/Port_of_Spain
- America/Port-au-Prince
- America/Porto_Acre
- America/Porto_Velho
- America/Puerto_Rico
- America/Rainy_River
- America/Rankin_Inlet
- America/Regina
- America/Rosario
- America/Santiago
- America/Santo_Domingo
- America/Sao_Paulo
- America/Scoresbysund
- America/Shiprock
- America/St_Johns
- America/St_Kitts
- America/St_Lucia
- America/St_Thomas
- America/St_Vincent
- America/Swift_Current
- America/Tegucigalpa
- America/Thule
- America/Thunder_Bay
- America/Tijuana
- America/Tortola
- America/Vancouver
- America/Whitehorse
- America/Winnipeg
- America/Yakutat
- America/Yellowknife
- Antarctica/South_Pole
- Asia/Aden
- Asia/Almaty
- Asia/Amman
- Asia/Anadyr
- Asia/Aqtau
- Asia/Aqtobe
- Asia/Ashgabat
- Asia/Ashkhabad
- Asia/Baghdad
- Asia/Bahrain
- Asia/Baku
- Asia/Bangkok
- Asia/Beirut
- Asia/Bishkek
- Asia/Brunei
- Asia/Calcutta
- Asia/Chungking
- Asia/Colombo
- Asia/Dacca
- Asia/Damascus
- Asia/Dili
- Asia/Dubai
- Asia/Dushanbe
- Asia/Gaza
- Asia/Harbin
- Asia/Hong_Kong
- Asia/Hovd
- Asia/Irkutsk
- Asia/Jakarta
- Asia/Jayapura
- Asia/Jerusalem
- Asia/Kabul
- Asia/Kamchatka
- Asia/Karachi
- Asia/Kashgar
- Asia/Katmandu
- Asia/Krasnoyarsk
- Asia/Kuala_Lumpur
- Asia/Kuching
- Asia/Kuwait
- Asia/Macao
- Asia/Magadan
- Asia/Manila
- Asia/Muscat
- Asia/Nicosia
- Asia/Novosibirsk
- Asia/Omsk
- Asia/Phnom_Penh
- Asia/Pyongyang
- Asia/Qatar
- Asia/Rangoon
- Asia/Riyadh
- Asia/Saigon
- Asia/Samarkand
- Asia/Seoul
- Asia/Shanghai
- Asia/Singapore
- Asia/Taipei
- Asia/Tashkent
- Asia/Tbilisi
- Asia/Tehran
- Asia/Thimbu
- Asia/Thimphu
- Asia/Tokyo
- Asia/Ujung_Pandang
- Asia/Ulaanbaatar
- Asia/Ulan_Bator
- Asia/Urumqi
- Asia/Vientiane
- Asia/Vladivostok
- Asia/Yakutsk
- Asia/Yekaterinburg
- Asia/Yerevan
- Atlantic/Azores
- Atlantic/Bermuda
- Atlantic/Canary
- Atlantic/Canary
- Atlantic/Cape_Verde
- Atlantic/Faeroe
- Atlantic/Jan_Mayen
- Atlantic/Madeira
- Atlantic/Reykjavik
- Atlantic/South_Georgia
- Atlantic/St_Helena
- Atlantic/Stanley
- Australia/Adelaide
- Australia/Brisbane
- Australia/Broken_Hill
- Australia/Darwin
- Australia/Hobart
- Australia/Lindeman
- Australia/Lord_Howe
- Australia/Melbourne
- Australia/Perth
- Australia/Sydney
- Canada/Atlantic
- Canada/Central
- Canada/Eastern
- Canada/East-Saskatchewan
- Canada/Mountain
- Canada/Newfoundland
- Canada/Pacific
- Canada/Saskatchewan
- Canada/Yukon
- Europe/Amsterdam
- Europe/Andorra
- Europe/Athens
- Europe/Belfast
- Europe/Belgrade
- Europe/Berlin
- Europe/Bratislava
- Europe/Brussels
- Europe/Bucharest
- Europe/Budapest
- Europe/Chisinau
- Europe/Copenhagen
- Europe/Dublin
- Europe/Gibraltar
- Europe/Helsinki
- Europe/Istanbul
- Europe/Kaliningrad
- Europe/Kiev
- Europe/Lisbon
- Europe/Ljubljana
- Europe/London
- Europe/Luxembourg
- Europe/Madrid
- Europe/Malta
- Europe/Minsk
- Europe/Monaco
- Europe/Moscow
- Europe/Oslo
- Europe/Paris
- Europe/Prague
- Europe/Riga
- Europe/Rome
- Europe/Samara
- Europe/San_Marino
- Europe/Sarajevo
- Europe/Simferopol
- Europe/Skopje
- Europe/Sofia
- Europe/Stockholm
- Europe/Tallinn
- Europe/Tirane
- Europe/Tiraspol
- Europe/Uzhgorod
- Europe/Vaduz
- Europe/Vatican
- Europe/Vienna
- Europe/Vilnius
- Europe/Warsaw
- Europe/Zagreb
- Europe/Zaporozhye
- Europe/Zurich
- Indian/Antananarivo
- Indian/Chagos
- Indian/Christmas
- Indian/Cocos
- Indian/Comoro
- Indian/Kerguelen
- Indian/Mahe
- Indian/Maldives
- Indian/Mauritius
- Indian/Mayotte
- Indian/Reunion
- Pacific/Apia
- Pacific/Auckland
- Pacific/Chatham
- Pacific/Easter
- Pacific/Efate
- Pacific/Enderbury
- Pacific/Fakaofo
- Pacific/Fiji
- Pacific/Funafuti
- Pacific/Galapagos
- Pacific/Gambier
- Pacific/Guadalcanal
- Pacific/Guam
- Pacific/Honolulu
- Pacific/Johnston
- Pacific/Kiritimati
- Pacific/Kosrae
- Pacific/Kwajalein
- Pacific/Majuro
- Pacific/Marquesas
- Pacific/Midway
- Pacific/Nauru
- Pacific/Niue
- Pacific/Norfolk
- Pacific/Noumea
- Pacific/Pago_Pago
- Pacific/Palau
- Pacific/Pitcairn
- Pacific/Ponape
- Pacific/Port_Moresby
- Pacific/Rarotonga
- Pacific/Saipan
- Pacific/Tahiti
- Pacific/Tarawa
- Pacific/Tongatapu
- Pacific/Truk
- Pacific/Wake
- Pacific/Wallis
- Pacific/Yap
18.3 New Methodology Session & Visitor Data
Statcounter is rolling out a new session and visitor counting methodology. This rollout is still at an early stage and is currently only available for accounts created after August 4 2016. However, for projects where this data is available, the new data can be retrieved in summary stats API calls by adding an extra url parameter to your request: &method=new e.g.
http://api.statcounter.com/stats/?vn=VERSION_NUMBER&s=summary&g=GRANULARITY&sd=START_DAY&sm=START_MONTH&sy=START_YEAR&ed=END_DAY&em=END_MONTH&ey=END_YEAR&pi=PROJECT_ID&method=new&t=TIME_OF_EXECUTION&u=USERNAME&f=FORMAT&sha1=SHA-1_TO_PROVE_IDENTITYWhen this parameter is passed, extra visitor and session data based on the new counting methodology will be returned in the API response, if the new counting methodology has been enabled for the project. The fields for this data are:
{ "sc_data": [{ ... "sessions": "SESSIONS", "returning_sessions": "RETURNING_SESSIONS", "visitors": "VISITORS", "new_visitors": "NEW_VISITORS" ... }] }These new fields will be returned in addition the standard fields already returned. If the project does not currently support the new counting methodology, the parameter is ignored and these extra fields will not be returned.
-
Last Update: 9th November 2017