PHP code example of dmt-software / ga4events
1. Go to this page and download the library: Download dmt-software/ga4events 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/ */
dmt-software / ga4events example snippets
DMT\GA4Events\GA4Helper;
// create an event
$searchEvent = GA4Helper::search(['searchTerm' => 'mret_hcraes']);
// or
$searchEvent = GA4Helper::search(['search_term' => 'mret_hcraes']);
// output the event in different formats
$gtagParams = GA4Helper::toGtag($searchEvent);
print_r($gtagParams);
/*
Array
(
[0] => event
[1] => search
[2] => Array
(
[search_term] => mret_hcraes
)
)
*/
$gtagScript = GA4Helper::toGtagScript($searchEvent, $;
*/