承接 stape/stape-sgtm-php 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

stape/stape-sgtm-php

最新稳定版本:1.0.0

Composer 安装命令:

composer require stape/stape-sgtm-php

包简介

Stape sGTM PHP SDK

README 文档

README

A PHP SDK to send tracking events to server-side GTM containers. Works in conjunction with Data Client.

Getting Started

Configuration

Fill in the basic parameters:

use Stape\Sgtm\StapeSGTM;

$sgtm = StapeSGTM::create('https://gtm.example.com', '/data');
Variable Description
$gtmServerDomain Server host
$requestPath Request processing path

Sending Event Data

$sgtm->sendEventData(<$eventName>, <$eventData>);
Variable Description
$eventName Event name
$eventData Array of options for forming event data

$eventData

$eventData = [
  'page_hostname' => 'Stape',
  'page_location' => 'http://stape.io',
  'page_path' => '/',
  'user_data' => [
    'sha256_email_address' => Transforms::sha256hex('jhonn@doe.com'),
    'address' => [
      'first_name' => 'Jhon',
    ],
  ],
];

Transforms

Option Description
trim Removes whitespace from the beginning and end of the value
base64 Encodes the string in Base64 format
md5 Encodes the string in MD5 format
sha256base64 Encodes the string in SHA256 Base64 format
sha256hex Encodes the string in SHA256 HEX format

Full Example

namespace Stape\Sgtm\Example;

use Stape\Sgtm\StapeSGTM;
use Stape\Sgtm\Transforms;

require_once __DIR__  . '/../vendor/autoload.php';

$start = StapeSGTM::create('https://gtm.stape.io', '/data?dhjdf=123');

$eventData = [
    'client_id' => '123456',
    'currency' => 'USD',
    'ip_override' => '79.144.123.69',
    'language' => 'en',
    'page_encoding' => 'UTF-8',
    'page_hostname' => 'Stape',
    'page_location' => 'http://stape.io',
    'page_path' => '/',
    'user_data' => [
        'sha256_email_address' => Transforms::sha256hex('jhonn@doe.com'),
        'phone_number' => '123456769',
        'address' => [
            'first_name' => 'Jhon',
        ],
    ],
];

var_dump($start->sendEventData('page_view', $eventData));

统计信息

  • 总下载量: 8.51k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 5
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2024-07-07