ga_push
545 sites
Security covered
Supported Push types
You can implement your own methods to communicate with GA.
Google nowadays let you communicate to analytics with the current push types:
Push types GA4 DataLayer Pageview Event Ecommerce Enhanced Ecommerce Social ExceptionsFeatures:
- Client and Server side tracking. You can choose which mode better fits your needs!
Dependencies:
- Google Analytics 4 Measurement Protocol PHP Library: https://github.com/br33f/php-GA4-Measurement-Protocol
Modules that uses ga_push as dependency
- Commerce Google Analytics (2.x) : commerce_google_analytics
Please let us know about new modules that uses GA Push!
Changes Introduced in 2.x Version
We removed the deprecated methods from GA, introduced the GA4 method and kept Datalayer.
We keep the same event types.
We keep the functions:
ga_push_add_ecommerce()
ga_push_add_event()
ga_push_add_pageview()
ga_push_add_social()
Removed options parameter from ga_push_add.
The following properties are not supported on GA4 service:
- * - 'tid': Override Tracking ID / Web Property ID (Classic User account
- * aka UA)
- * of the google analytics module config.
- * Universal and Classic GA Methods.
- * - 'cid': Override Universal Client ID of the current user cookie.
- * Only for Universal GA methods.
- * - 'utma': Force Classic GA __utma cookie of the current user cookie
- * Only for Classic GA methods.
- * - 'utmb': Force Classic GA __utmb cookie of the current user cookie
- * Only for Classic GA methods.
- * - 'ua': Override User Agent of the current user.
- * Only for Universal GA methods.
- * - 'uip': Override User IP of the current user.
- * Only for Universal GA methods.
We remove the includes and use services instead.
Example GA4:
/** @var \Drupal\ga_push\GA4MPService $ga4mpService **/
$ga4mpService = \Drupal::service('ga_push.ga4mp');
$form_url = 'https://example.com/your-form';
// Create the event data array
$event_data = [
'eventCategory' => 'LandingPage',
'eventAction' => 'Submit',
'eventLabel' => $form_url,
];
// Send the event
$ga4mpService->sendEvent($event_data, 'GA_PUSH_TYPE_EVENT');
Datalayer:
/** @var \Drupal\ga_push\DataLayerService $datalayerService **/
$datalayerService = \Drupal::service('ga_push.datalayer');
$form_url = 'https://example.com/your-form';
// Create the event data array
$event_data = [
'event' => 'GAEvent',
'eventCategory' => 'LandingPage',
'eventAction' => 'Submit',
'eventLabel' => $form_url,
];
// Send the event
$datalayerService->pushData($event_data, 'GA_PUSH_TYPE_EVENT');
Or use the functions ga_push_add*
Credits
Initial development by GeduR.
Development of this module is sponsored by Metadrop.