I need to record virtual Page Events with the Google Tag Manager PHP API.
So far I have this code:
$client = new Google_Client();
$client->setApplicationName("Partner Inquiry");
$client->setDeveloperKey("xxxxxxxx");
$service = new Google_Service_TagManager($client);
$eventName = new Google_Service_TagManager_Parameter();
$eventName->setList( array(
'event' => 'VirtualPageview',
'virtualPageURL' => '/partnerInquiry/partnerName',
'virtualPageTitle' => 'Partner Inquiry - Partner Name'
));
What do I call now.
My IDE autocompletion finds
$service->accounts
but how do I fire the event collection?
There is no server-to-server tracking with GTM. Even in mobile GTM, the container is first downloaded, and then interacted with as a local resource.
Google Tag Manager for the web is a JavaScript injector, which adds custom code into the document object model of a web page. Thus it has no tracking or data collection capabilities of its own. That's one of the major benefits: you are not reliant on Google's services other than the initial library download. Everything else takes place in the client's browser.
Use the Google Analytics Measurement Protocol library for PHP.
Example:
<?php
use TheIconic\Tracking\GoogleAnalytics\Analytics;
$analytics = new Analytics(true);
$analytics
->setProtocolVersion('1')
->setTrackingId('UA-12345678-90')
->setClientId('12345678')
->setDocumentPath('/mypage')
->setIpOverride("123.123.123.123");
$analytics->sendPageview();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With