PHP code example of spinbits / google-analytics-4-events-dto-s
1. Go to this page and download the library: Download spinbits/google-analytics-4-events-dto-s library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
spinbits / google-analytics-4-events-dto-s example snippets
php
$purchase = new Purchase($order->getNumber());
$purchase->setShipping($order->getShippingTotal());
$purchase->setTax($order->getTaxTotal());
$purchase->addItem(new Item('item_id', 'item_name', 1.00, 'USD'));
//get event as array
$purchase->jsonSerialize();
//get event as json
$json = (string) $purchase;