### Retrieve Realtime Overview with PHP SDK
Source: https://www.gosquared.com/docs/now/overview/php
Use this snippet to get a summary of site data, such as people online and active pages. Ensure the GoSquared PHP SDK is installed and configured with your site token and API key.
```php
require_once('gosquared-php-sdk/main.php');
$GS = new GoSquared(array(
'site_token' => 'GSN-106863-S',
'api_key' => 'demo'
));
$result = $GS->now->overview();
```
--------------------------------
### Example Event Tracking Request
Source: https://www.gosquared.com/docs/tracking/event/http
This example demonstrates how to make a POST request to the event tracking endpoint using cURL, including necessary API and site tokens.
```curl
curl -X POST -H "Content-Type: application/json" \
"https://api.gosquared.com/tracking/v1/event?api_key=demo&site_token=GSN-106863-S"
```
--------------------------------
### API Request Example
Source: https://www.gosquared.com/docs/configuration/http
Example of a POST request to the tracking API, including API key and site token. Ensure Content-Type is set to application/json for data POSTed.
```http
POST /tracking/v1/?api_key=demo&site_token=GSN-106863-S
```
--------------------------------
### Full HTML Page Example with GoSquared Tracking Code
Source: https://www.gosquared.com/docs/javascript-tracking-code/installation
An example of a complete HTML page including the GoSquared Analytics code snippet. Ensure the script is placed just before the closing `` tag.
```html
This is my website
The rest of my website is here
```
--------------------------------
### Install GoSquared Ruby Gem
Source: https://www.gosquared.com/docs/installation/ruby
Use this command to install the GoSquared Ruby Gem via RubyGems.
```bash
gem install gosquared
```
--------------------------------
### Track Transaction Directly
Source: https://www.gosquared.com/docs/javascript-tracking-code/track-transactions
This example shows how to track a transaction immediately using the `_gs('transaction', ...)` method, specifying transaction details and items.
```APIDOC
## Track Transaction Directly
### Description
This method allows you to track a transaction directly by providing its ID, options, and a list of items.
### Method
`_gs('transaction', transactionId, transactionOptions, items)`
### Parameters
- **transactionId** (String/Number) - Required - The unique identifier for the transaction.
- **transactionOptions** (Object) - Optional - Options to override default revenue and quantity calculations. Keys include `revenue` (String/Number) and `quantity` (Number).
- **items** (Array of Objects) - Optional - A list of items purchased in the transaction. Each item object can have `name` (String), `category`/`categories` (String/Array), `revenue` (String/Number), `quantity` (Number), and `price` (String/Number).
### Usage Example
```javascript
_gs('transaction', 'transaction-id', {
// track immediately
track: true,
// if you wish to explicitly set revenue and quantity totals
// for this transaction, specify them here. They will be used
// instead of the default totals calculated from the items.
// revenue: 50,
// quantity: 5
}, [
{
name: 'Product 1',
price: 1,
quantity: 4
},
{
name: 'Product 2',
price: 56,
category: 'Test Products'
}
]);
```
```
--------------------------------
### Retrieve All Webhooks
Source: https://www.gosquared.com/docs/account/webhooks/http
Use this endpoint to get a list of all configured webhooks. Requires API key and site token for authentication.
```bash
curl "https://api.gosquared.com/account/v1/webhooks?api_key=demo&site_token=GSN-106863-S"
```
--------------------------------
### Track Transaction with Items
Source: https://www.gosquared.com/docs/api/javascript-tracking-code/track-transactions
This example shows how to track a transaction with a unique ID, explicit revenue and quantity totals, and a list of purchased items.
```APIDOC
## Track Transaction with Items
### Description
Track a user transaction, specifying a unique ID, and optionally overriding the default revenue and quantity calculations by providing explicit totals. This method also accepts an array of item objects detailing the products purchased.
### Method
`_gs('transaction', transactionId, options, items)`
### Parameters
- **transactionId** (String/Number) - Required - The unique identifier for the transaction.
- **options** (Object) - Optional - Options for the transaction, such as `revenue` and `quantity` overrides.
- **revenue** (String/Number) - Optional - The total revenue for this transaction.
- **quantity** (Number) - Optional - The total number of items ordered.
- **items** (Array of Objects) - Optional - A list of items purchased in this transaction.
- **name** (String) - Required - The name of the item/product.
- **category** / **categories** (String/Array) - Optional - The category or categories the item belongs to.
- **revenue** (String/Number) - Optional - The total revenue from this item.
- **quantity** (Number) - Optional - The total number of this item ordered.
- **price** (String/Number) - Optional - The price per item.
### Request Example
```javascript
_gs('transaction', 'transaction-id', {
track: true,
revenue: 50,
quantity: 5
}, [
{
name: 'Product 1',
price: 1,
quantity: 4
},
{
name: 'Product 2',
price: 56,
category: 'Test Products'
}
]);
```
```
--------------------------------
### Retrieve All Sources
Source: https://www.gosquared.com/docs/now/sources/http
Use this endpoint to get a list of all sources that have referred visitors. You can filter by source type and control the number of results.
```bash
curl "https://api.gosquared.com/now/v3/sources?api_key=demo&site_token=GSN-106863-S"
```
--------------------------------
### Example Transaction Request
Source: https://www.gosquared.com/docs/tracking/transaction/http
Use this cURL command to send a POST request to the transaction endpoint. Ensure your API key and site token are correctly provided.
```bash
curl -X POST -H "Content-Type: application/json" \
"https://api.gosquared.com/tracking/v1/transaction?api_key=demo&site_token=GSN-106863-S"
```
--------------------------------
### Using the Transaction Object
Source: https://www.gosquared.com/docs/javascript-tracking-code/track-transactions
This example demonstrates how to use the transaction object returned by `_gs('transaction', ...)` to add items and track the transaction within a callback.
```APIDOC
## Using the Transaction Object
### Description
This method allows you to retrieve a transaction object, add items to it, and then track the transaction. This is useful when you need to build the transaction details incrementally.
### Method
`_gs(function() { ... })` with `_gs('transaction', transactionId)` inside.
### Parameters
- **transactionId** (String/Number) - Required - The unique identifier for the transaction.
### Transaction Object Methods
- `addItems(items)`: Adds a list of items to the transaction.
- `addItem(name, options)`: Adds a single item to the transaction.
- `track()`: Tracks the transaction.
### Usage Example
```javascript
_gs(function() {
var transaction = _gs('transaction', 'transaction-id');
transaction.addItems([
{
name: 'Product 1',
price: 1,
quantity: 4
},
{
name: 'Product 2',
price: 56,
category: 'Test Products'
}
]);
transaction.addItem('Product 3', {
revenue: 10,
categories: [ 'Test Products', 'Random Products' ]
});
transaction.track();
});
```
```
--------------------------------
### Trends API Request Example - Node.js
Source: https://www.gosquared.com/docs/trends/ruby
Example of how to make a request to the Trends API using Node.js. Ensure you have the necessary libraries installed.
```javascript
const gosquared = require('@gosquared/api');
gosquared.trends.v2.dimensionName({
from: 'YYYY-MM-DD',
to: 'YYYY-MM-DD',
interval: 'interval'
}).then(function(response) {
console.log(response);
});
```
--------------------------------
### Initialize GoSquared PHP SDK
Source: https://www.gosquared.com/docs/trends/sources/php
Instantiate the GoSquared SDK with your site token and API key. Ensure you have the SDK included via require_once.
```php
require_once('gosquared-php-sdk/main.php');
$GS = new GoSquared(array(
'site_token' => 'GSN-106863-S',
'api_key' => 'demo'
));
```
--------------------------------
### Initialize GoSquared PHP SDK
Source: https://www.gosquared.com/docs/installation/php
Include the GoSquared SDK and initialize it with your site token and API key. Ensure the SDK is placed in a directory included in your PHP include path.
```php
require_once('gosquared-php-sdk/main.php');
// initialise with your config
$GS = new GoSquared(array(
'site_token' => 'GSN-106863-S',
'api_key' => 'demo'
));
// good to go - call functions on $GS object
```
--------------------------------
### Retrieve List of Languages (PHP)
Source: https://www.gosquared.com/docs/now/languages/php
Use this snippet to get a list of languages for online visitors. Ensure you have the GoSquared PHP SDK installed and configured with your site token and API key.
```php
require_once('gosquared-php-sdk/main.php');
$GS = new GoSquared(array(
'site_token' => 'GSN-106863-S',
'api_key' => 'demo'
));
$result = $GS->now->languages();
```
--------------------------------
### Retrieve Current Time with GoSquared PHP SDK
Source: https://www.gosquared.com/docs/now/time/php
Use this snippet to get the current time from GoSquared's infrastructure. Ensure you have the gosquared-php-sdk installed and configured with your site token and API key.
```php
require_once('gosquared-php-sdk/main.php');
$GS = new GoSquared(array(
'site_token' => 'GSN-106863-S',
'api_key' => 'demo'
));
$result = $GS->now->time();
```
--------------------------------
### Create Site
Source: https://www.gosquared.com/docs/account/sites/http
Creates a new site for your account.
```APIDOC
## POST https://api.gosquared.com/account/v1/sites
### Description
Creates a new site for your account.
### Method
POST
### Endpoint
https://api.gosquared.com/account/v1/sites
### Authentication
API Key
### Parameters
* required
### Request Example
```json
{
"site_token": "GSN-106863-SPoolga - GSN-181546-E"
}
```
### Response
#### Success Response (200)
- **site_id** (string) - The ID of the newly created site.
- **site_token** (string) - The token for the newly created site.
```
--------------------------------
### Retrieve Pages with Online Visitors (Node.js)
Source: https://www.gosquared.com/docs/now/pages/node
Use this snippet to get a list of pages with active visitors. Ensure you have the GoSquared library installed and your API key and site token are correctly configured.
```javascript
var GoSquared = require('gosquared');
var gosquared = new GoSquared({
api_key: 'demo',
site_token: 'GSN-106863-S'
});
gosquared.now.v3.pages(function(err, res) {
if (err) return console.log(err);
console.log(res);
});
```
--------------------------------
### Initialize Ruby Library and Fetch People
Source: https://www.gosquared.com/docs/people/people/ruby
Instantiate the GoSquared Ruby library with your API key and site token, then fetch a list of people. Ensure your API key is authorized for the People API endpoint.
```ruby
require 'gosquared'
gs = Gosquared::RubyLibrary.new('demo','GSN-106863-S')
gs.people.people
gs.people.fetch
```
--------------------------------
### Retrieve OS Metrics with PHP SDK
Source: https://www.gosquared.com/docs/trends/os/php
Initializes the GoSquared SDK with site token and API key, then calls the trends->os() method to retrieve operating system metrics. Ensure your API key is authorized for this endpoint.
```php
require_once('gosquared-php-sdk/main.php');
$GS = new GoSquared(array(
'site_token' => 'GSN-106863-S',
'api_key' => 'demo'
));
$result = $GS->trends->os();
```
--------------------------------
### Initialize GoSquared Ruby Library and Fetch Campaigns
Source: https://www.gosquared.com/docs/now/campaigns/ruby
Instantiate the GoSquared Ruby library with your API key and site token, then call the campaigns method to retrieve real-time campaign data. Ensure your API key is authorized for the endpoint.
```ruby
require 'gosquared'
gs = Gosquared::RubyLibrary.new('demo','GSN-106863-S')
gs.now.campaigns
gs.now.fetch
```
--------------------------------
### Retrieve Pages with Online Visitors (GET)
Source: https://www.gosquared.com/docs/now/pages/http
Use this endpoint to get a list of pages with active visitors, ordered by visitor count. You can optionally specify a page URL to get information for a specific page.
```http
GEThttps://api.gosquared.com/now/v3/pages
```
```curl
curl "https://api.gosquared.com/now/v3/pages?api_key=demo&site_token=GSN-106863-S"
```
--------------------------------
### Initialize GoSquared Ruby Library and Retrieve Sites
Source: https://www.gosquared.com/docs/account/sites/ruby
Initializes the GoSquared Ruby library with an API key and site token, then retrieves a list of all accessible sites. Ensure you have valid credentials.
```ruby
require 'gosquared'
gs = Gosquared::RubyLibrary.new('demo','GSN-106863-S')
gs.account.sites
gs.account.fetch
```
--------------------------------
### Install GoSquared Node.js Module
Source: https://www.gosquared.com/docs/installation/node
Install the GoSquared Node.js module using npm. This command saves the package to your project's dependencies.
```bash
npm install --save gosquared
```
--------------------------------
### Initialize Ruby Library
Source: https://www.gosquared.com/docs/configuration/ruby
Instantiate the GoSquared Ruby library with your API key and project token. Ensure these credentials are valid and have the necessary scopes.
```ruby
gs = Gosquared::RubyLibrary.new('demo','GSN-106863-S')
```
--------------------------------
### Retrieve Realtime Overview
Source: https://www.gosquared.com/docs/now/overview
Use this endpoint to get a summary of your site's real-time data. It requires API key and site token for authentication. Optional parameters include date range and date format.
```bash
curl "https://api.gosquared.com/now/v3/overview?api_key=demo&site_token=GSN-106863-S"
```
--------------------------------
### Trends API Request Example - Ruby
Source: https://www.gosquared.com/docs/trends/ruby
Example of how to make a request to the Trends API using Ruby. This snippet shows a basic implementation.
```ruby
require 'gosquared'
gosquared = GoSquared::Client.new('YOUR_API_KEY')
response = gosquared.trends.v2.dimensionName({
from: 'YYYY-MM-DD',
to: 'YYYY-MM-DD',
interval: 'interval'
})
puts response
```
--------------------------------
### Trends API Request Example - PHP
Source: https://www.gosquared.com/docs/trends/ruby
Example of how to make a request to the Trends API using PHP. This snippet demonstrates basic usage.
```php
$gosquared = new \GoSquared\Client('YOUR_API_KEY');
$response = $gosquared->trends()->v2()->dimensionName([
'from' => 'YYYY-MM-DD',
'to' => 'YYYY-MM-DD',
'interval' => 'interval'
]);
print_r($response);
```
--------------------------------
### Initialize and Track Transactions in Ruby
Source: https://www.gosquared.com/docs/tracking/transaction/ruby
Initializes the GoSquared Ruby library with your API key and site ID, then demonstrates how to track a transaction and make a general post request.
```ruby
require 'gosquared'
gs = Gosquared::RubyLibrary.new('demo','GSN-106863-S')
gs.tracking.transaction
gs.tracking.post
```
--------------------------------
### PHP Trends API Request Example
Source: https://www.gosquared.com/docs/trends/php
Example of how to construct a Trends API request using PHP. This demonstrates setting the API endpoint, date range, and interval.
```PHP
```
--------------------------------
### Install GoSquared JavaScript Tracking Code
Source: https://www.gosquared.com/docs/javascript-tracking-code/installation
Copy and paste this snippet into every page you'd like to track, just before the closing `` tag. Remember to replace 'your-project-token' with your actual project token.
```javascript
!function(g,s,q,r,d){r=g[r]=g[r]||function(){(r.q=r.q||[]).push(arguments)};
d=s.createElement(q);d.src='//d1l6p2sc9645hc.cloudfront.net/gosquared.js';q=
s.getElementsByTagName(q)[0];q.parentNode.insertBefore(d,q)}(window,document
,'script','_gs');
_gs('your-project-token');
```
--------------------------------
### Initialize GoSquared Ruby Library
Source: https://www.gosquared.com/docs/account/webhooks/ruby
Instantiate the GoSquared Ruby library with your API key and site token. This is a prerequisite for all subsequent API calls.
```ruby
require 'gosquared'
gs = Gosquared::RubyLibrary.new('demo','GSN-106863-S')
```
--------------------------------
### Create Site
Source: https://www.gosquared.com/docs/account/sites/http
Adds a new website to your account. You must provide a name and a valid URL for the site. A timezone can also be specified; otherwise, it defaults to 'Europe/London'.
```APIDOC
## POST /sites
### Description
Adds a new website to your account.
### Method
POST
### Endpoint
/sites
### Parameters
#### Request Body
- **name** (String) - The name of the site.
- **url** (String) - Required. A valid http(s) url.
- **timezone** (String) - Default Value: `Europe/London`. A valid timezone. Accepted values: `Africa/Algiers, Atlantic/Cape_Verde, Africa/Ndjamena, Africa/Abidjan, Africa/Bamako, Africa/Banjul, Africa/Conakry, Africa/Dakar, Africa/Freetown, Africa/Lome, Africa/Nouakchott, Africa/Ouagadougou, Africa/Sao_Tome, Atlantic/St_Helena, Africa/Cairo, Africa/Accra, Africa/Bissau, Africa/Nairobi, Africa/Addis_Ababa, Africa/Asmara, Africa/Dar_es_Salaam, Africa/Djibouti, Africa/Kampala, Africa/Mogadishu, Indian/Antananarivo, Indian/Comoro, Indian/Mayotte, Africa/Monrovia, Africa/Tripoli, Indian/Mauritius, Africa/Casablanca, Africa/El_Aaiun, Africa/Maputo, Africa/Blantyre, Africa/Bujumbura, Africa/Gaborone, Africa/Harare, Africa/Kigali, Africa/Lubumbashi, Africa/Lusaka, Africa/Windhoek, Africa/Lagos, Africa/Bangui, Africa/Brazzaville, Africa/Douala, Africa/Kinshasa, Africa/Libreville, Africa/Luanda, Africa/Malabo, Africa/Niamey, Africa/Porto-Novo, Indian/Reunion, Indian/Mahe, Africa/Johannesburg, Africa/Maseru, Africa/Mbabane, Africa/Khartoum, Africa/Juba, Africa/Tunis, Antarctica/Casey, Antarctica/Davis, Antarctica/Mawson, Indian/Kerguelen, Antarctica/DumontDUrville, Antarctica/Syowa, Antarctica/Troll, Antarctica/Vostok, Antarctica/Rothera, Asia/Kabul, Asia/Yerevan, Asia/Baku, Asia/Dhaka, Asia/Thimphu, Indian/Chagos, Asia/Brunei, Asia/Rangoon, Asia/Shanghai, Asia/Urumqi, Asia/Hong_Kong, Asia/Taipei, Asia/Macau, Asia/Nicosia, Asia/Tbilisi, Asia/Dili, Asia/Kolkata, Asia/Jakarta, Asia/Pontianak, Asia/Makassar, Asia/Jayapura, Asia/Tehran, Asia/Baghdad, Asia/Jerusalem, Asia/Tokyo, Asia/Amman, Asia/Almaty, Asia/Qyzylorda, Asia/Aqtobe, Asia/Aqtau, Asia/Oral, Asia/Bishkek, Asia/Seoul, Asia/Pyongyang, Asia/Beirut, Asia/Kuala_Lumpur, Asia/Kuching, Indian/Maldives, Asia/Hovd, Asia/Ulaanbaatar, Asia/Choibalsan, Asia/Kathmandu, Asia/Karachi, Asia/Gaza, Asia/Hebron, Asia/Manila, Asia/Qatar, Asia/Bahrain, Asia/Riyadh, Asia/Aden, Asia/Kuwait, Asia/Singapore, Asia/Colombo, Asia/Damascus, Asia/Dushanbe, Asia/Bangkok, Asia/Phnom_Penh, Asia/Vientiane, Asia/Ashgabat, Asia/Dubai, Asia/Muscat, Asia/Samarkand, Asia/Tashkent, Asia/Ho_Chi_Minh, Australia/Darwin, Australia/Perth, Australia/Eucla, Australia/Brisbane, Australia/Lindeman, Australia/Adelaide, Australia/Hobart, Australia/Currie, Australia/Melbourne, Australia/Sydney, Australia/Broken_Hill, Australia/Lord_Howe, Antarctica/Macquarie, Indian/Christmas, Indian/Cocos, Pacific/Fiji, Pacific/Gambier, Pacific/Marquesas, Pacific/Tahiti, Pacific/Guam, Pacific/Saipan, Pacific/Tarawa, Pacific/Enderbury, Pacific/Kiritimati, Pacific/Majuro, Pacific/Kwajalein, Pacific/Chuuk, Pacific/Pohnpei, Pacific/Kosrae, Pacific/Nauru, Pacific/Noumea, Pacific/Auckland, Pacific/Chatham, Antarctica/McMurdo, Pacific/Rarotonga, Pacific/Niue, Pacific/Norfolk, Pacific/Palau, Pacific/Port_Moresby, Pacific/Bougainville, Pacific/Pitcairn, Pacific/Pago_Pago, Pacific/Midway, Pacific/Apia, Pacific/Guadalcanal, Pacific/Fakaofo, Pacific/Tongatapu, Pacific/Funafuti, Pacific/Wake, Pacific/Efate, Pacific/Wallis, Europe/London, Europe/Jersey, Europe/Guernsey, Europe/Isle_of_Man, Europe/Dublin, Europe/Tirane, Europe/Andorra, Europe/Vienna, Europe/Minsk, Europe/Brussels, Europe/Sofia, Europe/Prague, Europe/Copenhagen, Atlantic/Faroe, America/Danmarkshavn, America/Scoresbysund, America/Godthab, America/Thule, Europe/Tallinn, Europe/Helsinki, Europe/Mariehamn, Europe/Paris, Europe/Berlin, Europe/Busingen, Europe/Gibraltar, Europe/Athens, Europe/Budapest, Atlantic/Reykjavik, Europe/Rome, Europe/Vatican, Europe/San_Marino, Europe/Riga, Europe/Vaduz, Europe/Vilnius, Europe/Luxembourg, Europe/Malta, Europe/Chisinau, Europe/Monaco, Europe/Amsterdam, Europe/Oslo, Arctic/Longyearbyen, Europe/Warsaw, Europe/Lisbon, Atlantic/Azores, Atlantic/Madeira, Europe/Bucharest, Europe/Kaliningrad, Europe/Moscow, Europe/Simferopol, Europe/Volgograd, Europe/Samara, Asia/Yekaterinburg, Asia/Omsk, Asia/Novosibirsk, Asia/Novokuznetsk, Asia/Krasnoyarsk, Asia/Irkutsk, Asia/Chita, Asia/Yakutsk, Asia/Vladivostok, Asia/Khandyga, Asia/Sakhalin, Asia/Magadan, Asia/Srednekolymsk, Asia/Ust-Nera, Asia/Kamchatka, Asia/Anadyr, Europe/Belgrade, Europe/Ljubljana, Europe/Podgorica, Europe/Sarajevo, Europe/Skopje, Europe/Zagreb, Europe/Bratislava, Europe/Madrid, Africa/Ceuta, Atlantic/Canary, Europe/Stockholm, Europe/Zurich, Europe/Istanbul, Europe/Kiev, Europe/Uzhgorod, Europe/Zaporozhye, America/New_York, America/Chicago, America/North_Dakota/Center, America/North_Dakota/New_Salem, America/North_Dakota/Beulah, America/Denver, America/Los_Angeles, America/Juneau, America/Sitka, America/Metlakatla, America/Yakutat, America/Anchorage, America/Nome, America/Adak, Pacific/Honolulu, Pacific/Johnston, America/Phoenix, America/Boise, America/Indiana/Indianapolis, America/Indiana/Marengo, America/Indiana/Vincennes, America/Indiana/Tell_City, America/Indiana/Petersburg, America/Indiana/Knox, Ame`
### Request Example
```json
{
"name": "My Website",
"url": "https://example.com",
"timezone": "America/New_York"
}
```
### Response
#### Success Response (200)
- **id** (String) - The unique identifier for the created site.
- **name** (String) - The name of the site.
- **url** (String) - The URL of the site.
- **timezone** (String) - The timezone of the site.
#### Response Example
```json
{
"id": "site_12345",
"name": "My Website",
"url": "https://example.com",
"timezone": "America/New_York"
}
```
```
--------------------------------
### Example Archived Chats API Request
Source: https://www.gosquared.com/docs/chat/archivedChats/http
Example of a cURL request to retrieve archived chats. Ensure you replace 'demo' and 'GSN-106863-S' with your actual API key and site token.
```curl
curl "https://api.gosquared.com/chat/v1/archivedChats?api_key=demo&site_token=GSN-106863-S"
```
--------------------------------
### Create a New Site
Source: https://www.gosquared.com/docs/account/sites/http
Use this cURL command to create a new site within your GoSquared account. Ensure you replace 'demo' with your actual API key.
```bash
curl -X POST -H "Content-Type: application/json" \
"https://api.gosquared.com/account/v1/sites?api_key=demo"
```
--------------------------------
### Get Token Info (HTTP)
Source: https://www.gosquared.com/docs/auth/tokeninfo/php
Make a GET request to the /auth/v1/tokeninfo endpoint to retrieve information about the provided authorization token. This includes a 'scopes' property detailing the token's access level.
```http
GET https://api.gosquared.com/auth/v1/tokeninfo
```
--------------------------------
### Retrieve Sites with GoSquared PHP SDK
Source: https://www.gosquared.com/docs/account/sites/php
Initializes the GoSquared PHP SDK and retrieves a list of all accessible sites for the authenticated account. Ensure you have the 'gosquared-php-sdk' library installed.
```php
require_once('gosquared-php-sdk/main.php');
$GS = new GoSquared(array(
'site_token' => 'GSN-106863-S',
'api_key' => 'demo'
));
$result = $GS->account->sites();
```
--------------------------------
### Create Site
Source: https://www.gosquared.com/docs/account/sites/ruby
Creates a new site associated with the account. Requires a name, URL, and optionally a timezone.
```APIDOC
## POST /sites
### Description
Creates a new site for the account.
### Method
POST
### Endpoint
/sites
### Parameters
#### Request Body
- **name** (String) - The name of the site.
- **url** (String) - Required. A valid http(s) url.
- **timezone** (String) - Default Value: `Europe/London`. A valid timezone. Accepted values: `Africa/Algiers, Atlantic/Cape_Verde, Africa/Ndjamena, Africa/Abidjan, Africa/Bamako, Africa/Banjul, Africa/Conakry, Africa/Dakar, Africa/Freetown, Africa/Lome, Africa/Nouakchott, Africa/Ouagadougou, Africa/Sao_Tome, Atlantic/St_Helena, Africa/Cairo, Africa/Accra, Africa/Bissau, Africa/Nairobi, Africa/Addis_Ababa, Africa/Asmara, Africa/Dar_es_Salaam, Africa/Djibouti, Africa/Kampala, Africa/Mogadishu, Indian/Antananarivo, Indian/Comoro, Indian/Mayotte, Africa/Monrovia, Africa/Tripoli, Indian/Mauritius, Africa/Casablanca, Africa/El_Aaiun, Africa/Maputo, Africa/Blantyre, Africa/Bujumbura, Africa/Gaborone, Africa/Harare, Africa/Kigali, Africa/Lubumbashi, Africa/Lusaka, Africa/Windhoek, Africa/Lagos, Africa/Bangui, Africa/Brazzaville, Africa/Douala, Africa/Kinshasa, Africa/Libreville, Africa/Luanda, Africa/Malabo, Africa/Niamey, Africa/Porto-Novo, Indian/Reunion, Indian/Mahe, Africa/Johannesburg, Africa/Maseru, Africa/Mbabane, Africa/Khartoum, Africa/Juba, Africa/Tunis, Antarctica/Casey, Antarctica/Davis, Antarctica/Mawson, Indian/Kerguelen, Antarctica/DumontDUrville, Antarctica/Syowa, Antarctica/Troll, Antarctica/Vostok, Antarctica/Rothera, Asia/Kabul, Asia/Yerevan, Asia/Baku, Asia/Dhaka, Asia/Thimphu, Indian/Chagos, Asia/Brunei, Asia/Rangoon, Asia/Shanghai, Asia/Urumqi, Asia/Hong_Kong, Asia/Taipei, Asia/Macau, Asia/Nicosia, Asia/Tbilisi, Asia/Dili, Asia/Kolkata, Asia/Jakarta, Asia/Pontianak, Asia/Makassar, Asia/Jayapura, Asia/Tehran, Asia/Baghdad, Asia/Jerusalem, Asia/Tokyo, Asia/Amman, Asia/Almaty, Asia/Qyzylorda, Asia/Aqtobe, Asia/Aqtau, Asia/Oral, Asia/Bishkek, Asia/Seoul, Asia/Pyongyang, Asia/Beirut, Asia/Kuala_Lumpur, Asia/Kuching, Indian/Maldives, Asia/Hovd, Asia/Ulaanbaatar, Asia/Choibalsan, Asia/Kathmandu, Asia/Karachi, Asia/Gaza, Asia/Hebron, Asia/Manila, Asia/Qatar, Asia/Bahrain, Asia/Riyadh, Asia/Aden, Asia/Kuwait, Asia/Singapore, Asia/Colombo, Asia/Damascus, Asia/Dushanbe, Asia/Bangkok, Asia/Phnom_Penh, Asia/Vientiane, Asia/Ashgabat, Asia/Dubai, Asia/Muscat, Asia/Samarkand, Asia/Tashkent, Asia/Ho_Chi_Minh, Australia/Darwin, Australia/Perth, Australia/Eucla, Australia/Brisbane, Australia/Lindeman, Australia/Adelaide, Australia/Hobart, Australia/Currie, Australia/Melbourne, Australia/Sydney, Australia/Broken_Hill, Australia/Lord_Howe, Antarctica/Macquarie, Indian/Christmas, Indian/Cocos, Pacific/Fiji, Pacific/Gambier, Pacific/Marquesas, Pacific/Tahiti, Pacific/Guam, Pacific/Saipan, Pacific/Tarawa, Pacific/Enderbury, Pacific/Kiritimati, Pacific/Majuro, Pacific/Kwajalein, Pacific/Chuuk, Pacific/Pohnpei, Pacific/Kosrae, Pacific/Nauru, Pacific/Noumea, Pacific/Auckland, Pacific/Chatham, Antarctica/McMurdo, Pacific/Rarotonga, Pacific/Niue, Pacific/Norfolk, Pacific/Palau, Pacific/Port_Moresby, Pacific/Bougainville, Pacific/Pitcairn, Pacific/Pago_Pago, Pacific/Midway, Pacific/Apia, Pacific/Guadalcanal, Pacific/Fakaofo, Pacific/Tongatapu, Pacific/Funafuti, Pacific/Wake, Pacific/Efate, Pacific/Wallis, Europe/London, Europe/Jersey, Europe/Guernsey, Europe/Isle_of_Man, Europe/Dublin, Europe/Tirane, Europe/Andorra, Europe/Vienna, Europe/Minsk, Europe/Brussels, Europe/Sofia, Europe/Prague, Europe/Copenhagen, Atlantic/Faroe, America/Danmarkshavn, America/Scoresbysund, America/Godthab, America/Thule, Europe/Tallinn, Europe/Helsinki, Europe/Mariehamn, Europe/Paris, Europe/Berlin, Europe/Busingen, Europe/Gibraltar, Europe/Athens, Europe/Budapest, Atlantic/Reykjavik, Europe/Rome, Europe/Vatican, Europe/San_Marino, Europe/Riga, Europe/Vaduz, Europe/Vilnius, Europe/Luxembourg, Europe/Malta, Europe/Chisinau, Europe/Monaco, Europe/Amsterdam, Europe/Oslo, Arctic/Longyearbyen, Europe/Warsaw, Europe/Lisbon, Atlantic/Azores, Atlantic/Madeira, Europe/Bucharest, Europe/Kaliningrad, Europe/Moscow, Europe/Simferopol, Europe/Volgograd, Europe/Samara, Asia/Yekaterinburg, Asia/Omsk, Asia/Novosibirsk, Asia/Novokuznetsk, Asia/Krasnoyarsk, Asia/Irkutsk, Asia/Chita, Asia/Yakutsk, Asia/Vladivostok, Asia/Khandyga, Asia/Sakhalin, Asia/Magadan, Asia/Srednekolymsk, Asia/Ust-Nera, Asia/Kamchatka, Asia/Anadyr, Europe/Belgrade, Europe/Ljubljana, Europe/Podgorica, Europe/Sarajevo, Europe/Skopje, Europe/Zagreb, Europe/Bratislava, Europe/Madrid, Africa/Ceuta, Atlantic/Canary, Europe/Stockholm, Europe/Zurich, Europe/Istanbul, Europe/Kiev, Europe/Uzhgorod, Europe/Zaporozhye, America/New_York, America/Chicago, America/North_Dakota/Center, America/North_Dakota/New_Salem, America/North_Dakota/Beulah, America/Denver, America/Los_Angeles, America/Juneau, America/Sitka, America/Metlakatla, America/Yakutat, America/Anchorage, America/Nome, America/Adak, Pacific/Honolulu, Pacific/Johnston, America/Phoenix, America/Boise, America/Indiana/Indianapolis, America/Indiana/Marengo, America/Indiana/Vincennes, America/Indiana/Tell_City, America/Indiana/Petersburg, America/Indiana/Knox, Ame`
### Request Example
```json
{
"name": "My Website",
"url": "https://example.com",
"timezone": "America/New_York"
}
```
### Response
#### Success Response (200)
- **id** (String) - The unique identifier for the created site.
- **name** (String) - The name of the site.
- **url** (String) - The URL of the site.
- **timezone** (String) - The timezone of the site.
#### Response Example
```json
{
"id": "site_12345",
"name": "My Website",
"url": "https://example.com",
"timezone": "America/New_York"
}
```
```
--------------------------------
### Transaction POST Body Example
Source: https://www.gosquared.com/docs/tracking/transaction
This is an example of the POST body structure for tracking a transaction. It includes required fields like visitor ID and transaction details, along with optional item information.
```json
{
"visitor_id": "anonymous-visitor-id",
"timestamp": "2013-09-01T10:00:00Z",
"transaction": {
"id": "T12345",
"revenue": 19.99,
"quantity": 2,
"items": [
{
"name": "T-Shirt",
"price": 9.99,
"quantity": 2,
"revenue": 19.98,
"categories": ["Apparel", "T-Shirts"]
}
]
}
}
```
--------------------------------
### Retrieve OS Metrics with Node.js
Source: https://www.gosquared.com/docs/trends/os/node
Use this snippet to fetch summarized operating system metrics. Ensure you have the GoSquared library installed and provide your API key and site token.
```javascript
var GoSquared = require('gosquared');
var gosquared = new GoSquared({
api_key: 'demo',
site_token: 'GSN-106863-S'
});
gosquared.trends.v2.os(function(err, res) {
if (err) return console.log(err);
console.log(res);
});
```
--------------------------------
### Get Person Feed
Source: https://www.gosquared.com/docs/people/people/http
Retrieves the feed for a specific person using their ID.
```APIDOC
## GET /people/v1/people/{personID}/feed
### Description
Retrieves the feed associated with a specific person.
### Method
GET
### Endpoint
/people/v1/people/{personID}/feed
### Parameters
#### Query Parameters
- **api_key** (string) - Required - Your API key.
- **site_token** (string) - Required - The site token for your GoSquared account.
### Request Example
```curl
https://api.gosquared.com/people/v1/people/{personID}/feed?api_key=demo&site_token=GSN-106863-S
```
### Response
#### Success Response (200)
- **feed** (array) - A list of feed items for the person.
#### Response Example
```json
{
"feed": [
{
"timestamp": "2023-10-27T10:00:00Z",
"type": "note",
"content": "User contacted support."
}
]
}
```
```
--------------------------------
### Retrieve Realtime Overview with Ruby
Source: https://www.gosquared.com/docs/now/overview/ruby
Initializes the GoSquared Ruby library and fetches the real-time overview data for the site. Ensure your API key is authorized for this endpoint.
```ruby
require 'gosquared'
gs = Gosquared::RubyLibrary.new('demo','GSN-106863-S')
gs.now.overview
gs.now.fetch
```
--------------------------------
### People API - Get Devices
Source: https://www.gosquared.com/docs/people/php
Retrieves the device information for a specific user.
```APIDOC
## GET /people/{id}/devices
### Description
Retrieves the device information associated with a specific user, providing insights into the technology they use.
### Method
GET
### Endpoint
/people/{id}/devices
### Parameters
#### Path Parameters
- **id** (string) - Required - The unique identifier of the user.
### Response
#### Success Response (200)
- **devices** (array) - A list of device objects associated with the user.
### Response Example
{
"devices": [
{
"type": "desktop",
"browser": "Chrome",
"os": "Windows 10"
}
]
}
```
--------------------------------
### Example Request for All Property Types
Source: https://www.gosquared.com/docs/api/people/propertyTypes
Use this cURL command to retrieve all property types. Ensure you replace 'demo' and 'GSN-106863-S' with your actual API key and site token.
```curl
curl "https://api.gosquared.com/people/v1/propertyTypes?api_key=demo&site_token=GSN-106863-S"
```
--------------------------------
### People API - Get Devices for Person
Source: https://www.gosquared.com/docs/people/ruby
Retrieves the device information for a specific user.
```APIDOC
## GET /people/{id}/devices
### Description
Retrieves all device information associated with a specific user, providing insights into the technology they use.
### Method
GET
### Endpoint
/people/{id}/devices
### Parameters
#### Path Parameters
- **id** (string) - Required - The unique identifier of the user.
### Response
#### Success Response (200)
- **devices** (array) - A list of device objects for the user.
- **type** (string) - The type of device (e.g., 'desktop', 'mobile').
- **browser** (string) - The browser used.
- **os** (string) - The operating system.
### Response Example
{
"devices": [
{
"type": "desktop",
"browser": "Chrome",
"os": "Windows"
},
{
"type": "mobile",
"browser": "Safari",
"os": "iOS"
}
]
}
```
--------------------------------
### Initialize GoSquared PHP SDK and Retrieve Page Data
Source: https://www.gosquared.com/docs/trends/page/php
This snippet demonstrates how to initialize the GoSquared PHP SDK with your site token and API key, and then make a request to retrieve page data. Ensure you have the 'gosquared-php-sdk' library installed.
```php
require_once('gosquared-php-sdk/main.php');
$GS = new GoSquared(array(
'site_token' => 'GSN-106863-S',
'api_key' => 'demo'
));
$result = $GS->trends->page();
```
--------------------------------
### People API - Get Smart Groups
Source: https://www.gosquared.com/docs/people/php
Retrieves a list of all configured Smart Groups.
```APIDOC
## GET /people/smartgroups
### Description
Retrieves a list of all Smart Groups configured within the People dashboard. These groups are used for managing and filtering users.
### Method
GET
### Endpoint
/people/smartgroups
### Response
#### Success Response (200)
- **smart_groups** (array) - A list of smart group objects, each containing group details.
### Response Example
{
"smart_groups": [
{
"id": "group_xyz",
"name": "New Signups",
"description": "Users who signed up in the last 7 days"
}
]
}
```
--------------------------------
### Create Site
Source: https://www.gosquared.com/docs/account/sites/node
Creates a new site within the account. Requires site name, URL, and optionally a timezone.
```APIDOC
## POST /sites
### Description
Creates a new site within the account.
### Method
POST
### Endpoint
/sites
### Parameters
#### Request Body
- **name** (String) - The name of the site.
- **url** (String) - Required. A valid http(s) url.
- **timezone** (String) - Default Value: `Europe/London`. A valid timezone. Accepted values: [list of accepted timezones]
```
--------------------------------
### Retrieve Sites using Node.js
Source: https://www.gosquared.com/docs/account/sites/node
Demonstrates how to retrieve a list of all sites associated with an account using the GoSquared Node.js client library. Ensure you have initialized the library with your API key and site token.
```javascript
var GoSquared = require('gosquared');
var gosquared = new GoSquared({
api_key: 'demo',
site_token: 'GSN-106863-S'
});
gosquared.account.v1.sites(function(err, res) {
if (err) return console.log(err);
console.log(res);
});
```
--------------------------------
### People API - Get Person by ID
Source: https://www.gosquared.com/docs/people/ruby
Retrieves a specific tracked user by their unique ID.
```APIDOC
## GET /people/{id}
### Description
Retrieves a single tracked user's data using their unique identifier.
### Method
GET
### Endpoint
/people/{id}
### Parameters
#### Path Parameters
- **id** (string) - Required - The unique identifier of the user to retrieve.
### Response
#### Success Response (200)
- **person** (object) - The user object.
- **id** (string) - The unique identifier for the user.
- **properties** (object) - Key-value pairs of user properties.
### Response Example
{
"person": {
"id": "user_123",
"properties": {
"name": "John Doe",
"email": "john.doe@example.com"
}
}
}
```
--------------------------------
### People API - Get Person's Feed
Source: https://www.gosquared.com/docs/people/php
Retrieves the feed of events for a specific user.
```APIDOC
## GET /people/{id}/feed
### Description
Retrieves the chronological feed of interactions for a specific user, including pageviews, custom events, and integrations.
### Method
GET
### Endpoint
/people/{id}/feed
### Parameters
#### Path Parameters
- **id** (string) - Required - The unique identifier of the user.
#### Query Parameters
- **event_name** (string) - Optional - Filters the feed to include only events with a specific name.
### Response
#### Success Response (200)
- **feed** (array) - A list of event objects representing the user's interactions.
### Response Example
{
"feed": [
{
"event_id": "event_abc",
"name": "pageview",
"timestamp": "2023-10-27T09:55:00Z",
"data": {
"url": "/homepage"
}
},
{
"event_id": "event_def",
"name": "signup_completed",
"timestamp": "2023-10-27T09:50:00Z",
"data": {}
}
]
}
```