RetailCRM API Client

WebAnalytics extends AbstractApiResourceGroup

Class WebAnalytics

Tags
category

WebAnalytics

SuppressWarnings

(PHPMD.CouplingBetweenObjects)

Table of Contents

Methods

clientIdsUpload()  : ClientIdUploadResponse
Makes POST "/api/v5/web-analytics/client-ids/upload" request.
sourcesUpload()  : SourcesUploadResponse
Makes POST "/api/v5/web-analytics/client-ids/upload" request.
visitsUpload()  : VisitsUploadResponse
Makes POST "/api/v5/web-analytics/client-ids/upload" request.

Methods

clientIdsUpload()

Makes POST "/api/v5/web-analytics/client-ids/upload" request.

public clientIdsUpload(ClientIdUploadRequest $request) : ClientIdUploadResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\WebAnalytics\ClientId;
use RetailCrm\Api\Model\Entity\WebAnalytics\Customer;
use RetailCrm\Api\Model\Entity\WebAnalytics\Order;
use RetailCrm\Api\Model\Request\WebAnalytics\ClientIdUploadRequest;

$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');

$entity = new ClientId();
$entity->value = 'value';
$entity->order = new Order();
$entity->order->id = 10;
$entity->order->externalId = 'externalId';
$entity->order->number = 'number';
$entity->customer = new Customer();
$entity->customer->id = 10;
$entity->customer->externalId = 'externalId';

$request = new ClientIdUploadRequest([$entity]);

try {
    $response = $client->webAnalytics->clientIdsUpload($request);
} catch (ApiExceptionInterface $exception) {
    echo sprintf(
        'Error from RetailCRM API (status code: %d): %s',
        $exception->getStatusCode(),
        $exception->getMessage()
    );

    if (count($exception->getErrorResponse()->errors) > 0) {
        echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
    }

    return;
}

echo 'Upload is successful';
Parameters
$request : ClientIdUploadRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
ClientIdUploadResponse

sourcesUpload()

Makes POST "/api/v5/web-analytics/client-ids/upload" request.

public sourcesUpload(SourcesUploadRequest $request) : SourcesUploadResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\WebAnalytics\Customer;
use RetailCrm\Api\Model\Entity\WebAnalytics\Order;
use RetailCrm\Api\Model\Entity\WebAnalytics\Source;
use RetailCrm\Api\Model\Request\WebAnalytics\SourcesUploadRequest;

$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');

$entity = new Source();
$entity->source = "sourse";
$entity->medium = "medium";
$entity->campaign = "campaign";
$entity->keyword = "keyword";
$entity->content = "content";
$entity->clientId = "10";
$entity->order = new Order();
$entity->order->id = 10;
$entity->order->externalId = "externalId";
$entity->order->number = "number";
$entity->customer = new Customer();
$entity->customer->id = 10;
$entity->customer->externalId = 'externalId';

$request = new SourcesUploadRequest([$entity]);

try {
    $response = $client->webAnalytics->sourcesUpload($request);
} catch (ApiExceptionInterface $exception) {
    echo sprintf(
        'Error from RetailCRM API (status code: %d): %s',
        $exception->getStatusCode(),
        $exception->getMessage()
    );

    if (count($exception->getErrorResponse()->errors) > 0) {
        echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
    }

    return;
}

echo 'Upload is successful';
Parameters
$request : SourcesUploadRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
SourcesUploadResponse

visitsUpload()

Makes POST "/api/v5/web-analytics/client-ids/upload" request.

public visitsUpload(VisitsUploadRequest $request) : VisitsUploadResponse

Example:

use RetailCrm\Api\Factory\SimpleClientFactory;
use RetailCrm\Api\Interfaces\ApiExceptionInterface;
use RetailCrm\Api\Model\Entity\WebAnalytics\Visit;
use RetailCrm\Api\Model\Entity\WebAnalytics\Customer;
use RetailCrm\Api\Model\Request\WebAnalytics\VisitsUploadRequest;

$client = SimpleClientFactory::createClient('https://test.retailcrm.pro', 'apiKey');

$entity = new Visit();
$dateTime = new \DateTime('2023-12-06T12:00:00');
$entity->createdAt = $dateTime->format('Y-m-d H:i:s');
$entity->visitLength = 10;
$entity->exitPage = '/exit-page';
$entity->landingPage = '/landing-page';
$entity->pageViews = 5;
$entity->pageDepth = 3;
$entity->customer = new Customer();
$entity->customer->id = 10;
$entity->customer->externalId = 'externalId';
$entity->source = new Source();
$entity->source = "sourse";
$entity->medium = "medium";
$entity->campaign = "campaign";
$entity->keyword = "keyword";
$entity->content = "content";
$page1 = new Page();
$page1->url = ('/page1');
$page1->title = ('Page 1');
$page1->countViews = 2;
$page1->timeOnPage = 60;
$page2 = new Page();
$page2->url = ('/page2');
$page2->title = ('Page 2');
$page2->countViews = 3;
$page2->timeOnPage = 45;
$pages = [$page1, $page2];
$entity->pages = $pages;
$entity->clientId = '123456';
$entity->site = 'example.com';

$request = new VisitsUploadRequest([$entity]);

try {
    $response = $client->webAnalytics->visitsUpload($request);
} catch (ApiExceptionInterface $exception) {
    echo sprintf(
        'Error from RetailCRM API (status code: %d): %s',
        $exception->getStatusCode(),
        $exception->getMessage()
    );

    if (count($exception->getErrorResponse()->errors) > 0) {
        echo PHP_EOL . 'Errors: ' . implode(', ', $exception->getErrorResponse()->errors);
    }

    return;
}

echo 'Upload is successful';
Parameters
$request : VisitsUploadRequest
Tags
throws
ApiExceptionInterface
throws
ClientExceptionInterface
throws
AccountDoesNotExistException
throws
ApiErrorException
throws
MissingCredentialsException
throws
MissingParameterException
throws
ValidationException
throws
HandlerException
throws
HttpClientException
Return values
VisitsUploadResponse

        
On this page

Search results