<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
baibaratsky / yii2-ga-measurement-protocol example snippets
'components' => [
'ga' => [
'class' => 'baibaratsky\yii\google\analytics\MeasurementProtocol',
'trackingId' => 'UA-XXXX-Y', // Put your real tracking ID here
// These parameters are optional:
'useSsl' => true, // If you’d like to use a secure connection to Google servers
'overrideIp' => false, // By default, IP is overridden by the user’s one, but you can disable this
'anonymizeIp' => true, // If you want to anonymize the sender’s IP address
'asyncMode' => true, // Enables the asynchronous mode (see below)
'autoSetClientId' => true, // Try to set ClientId automatically from the “_ga” cookie (disabled by default)
],
],
$request = \Yii::$app->ga->request();
// Build the order data programmatically, each product of the order included in the payload
// First, general and iliation('THE ICONIC')
->setRevenue(250.0)
->setTax(25.0)
->setShipping(15.0)
->setCouponCode('MY_COUPON');
// Include a product, the only roductData1);
// You can set the product action, which is PURCHASE in the example below
$request->setProductActionToPurchase();
// Finally, you need to send a hit; in this example, we are sending an Event
$request->setEventCategory('Checkout')
->setEventAction('Purchase')
->sendEvent();