Google 跟踪代码管理器 PHP API 中 dataLayer.push 的等价物

Equivalent of dataLayer.push in Google Tag Manager PHP API

我需要使用 Google 标签管理器 PHP API.

记录虚拟页面事件

到目前为止我有这个代码:

    $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'
    ));

我现在叫什么。

我的 IDE 自动完成发现

    $service->accounts

但是我该如何触发事件集合?

GTM 没有服务器到服务器的跟踪。即使在移动 GTM 中,容器也会先下载,然后作为本地资源进行交互。

Google 网页版跟踪代码管理器是一个 JavaScript 注入器,可将自定义代码添加到网页的文档对象模型中。因此,它没有自己的跟踪或数据收集能力。这是主要好处之一:除了初始库下载之外,您不依赖于 Google 的服务。其他一切都发生在客户端的浏览器中。

使用Google Analytics Measurement Protocol library for PHP.

示例:

<?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();