/Documentation

Stape PHP SDK

Updated Jan 28, 2026

Overview of Stape PHP SDK

How to set up Stape PHP SDK

Getting Started

Configuration

use Stape\Sgtm\StapeSGTM; $sgtm = StapeSGTM::create('https://gtm.example.com', '/data');
VariableDescription

Sending Event Data

$sgtm->sendEventData(<$eventName>, <$eventData>);
VariableDescription

$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

OptionDescription

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

Stape Data Client in server GTM

How to add Stape PHP SDK to your project

composer require stape/stape-sgtm-php
require_once __DIR__ . '/vendor/autoload.php'; use Stape\Sgtm\StapeSGTM; use Stape\Sgtm\Transforms; $sgtm = StapeSGTM::create('https://gtm.example.com', '/data'); $eventData = [     'value' => 68,     'currency' => 'USD',     'page_hostname' => 'stape.io',     'page_location' => 'http://stape.io',     'user_data' => [         'email' => Transforms::sha256hex('jhonn@doe.com'),     ], ]; $response = $sgtm->sendEventData('add_to_cart', $eventData); if ($response) {     echo "✅ Event sent successfully!"; } else {     echo "❌ Failed to send event."; }

How to test the setup

The most common problem when using the SDK is getting a 400 error

Was this article helpful?

Comments

Can’t find what you are looking for?