相当于Google跟踪代码管理器PHP API中的dataLayer.push

时间:2015-06-12 10:44:55

标签: php api google-tag-manager

我需要使用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

但如何触发事件集合?

2 个答案:

答案 0 :(得分:4)

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

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

答案 1 :(得分:2)

使用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();
相关问题