Your IP : 3.139.72.173
<?
require($_SERVER['DOCUMENT_ROOT'].'/bitrix/header.php');
require_once 'vendor/autoload.php';
echo "start\n";
use TheIconic\Tracking\GoogleAnalytics\Analytics;
$code = getGaCode();
echo "GA: $code was code";
$analytics = new Analytics(true);
// Build the order data programmatically, including each order product in the payload
// Take notice, if you want GA reports to tie this event with previous user actions
// you must get and set the same ClientId from the GA Cookie
// First, general and required hit data
$analytics->setProtocolVersion('1')
->setTrackingId('UA-51062187-2')
->setClientId(getGaCode())
->setUserId('123');
// Then, include the transaction data
$analytics->setTransactionId('7778922')
->setAffiliation('THE ICONIC')
->setRevenue(250.0)
->setTax(25.0)
->setShipping(15.0)
->setCouponCode('MY_COUPON');
// Include a product
$productData1 = [
'sku' => 'AAAA-6666',
'name' => 'Test Product 2',
'brand' => 'Test Brand 2',
'category' => 'Test Category 3/Test Category 4',
'variant' => 'yellow',
'price' => 50.00,
'quantity' => 1,
'coupon_code' => 'TEST 2',
'position' => 2
];
$analytics->addProduct($productData1);
// You can include as many products as you need this way
$productData2 = [
'sku' => 'AAAA-5555',
'name' => 'Test Product',
'brand' => 'Test Brand',
'category' => 'Test Category 1/Test Category 2',
'variant' => 'blue',
'price' => 85.00,
'quantity' => 2,
'coupon_code' => 'TEST',
'position' => 4
];
$analytics->addProduct($productData2);
// Don't forget to set the product action, in this case to PURCHASE
$analytics->setProductActionToPurchase();
// Finally, you must send a hit, in this case we send an Event
$response = $analytics->setDebug(true) ->setEventCategory('Checkout')
->setEventAction('Purchase')
->sendEvent();
$debugResponse = $response->getDebugResponse();
pre1($debugResponse);
echo "\nend";
function getGaCode() {
// Check fo cookie
$name = "_ga";
if (!isset($_COOKIE[$name])) {
return null;
}
// Parse cookie _ga='<something>.<something>.<clientid>.<timestamp>';
return explode(".", $_COOKIE[$name])[2];
}
require($_SERVER['DOCUMENT_ROOT'].'/bitrix/footer.php');
?>