tapbuy / redirect-tracking
Tapbuy module for redirect and tracking
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Type:magento2-module
Requires
- php: ~7.3.0||~7.4.0||~8.1.0
- magento/framework: 103.0.*
- magento/module-checkout: 100.4.*
- magento/module-sales: 103.0.*
- phpseclib/phpseclib: ^3.0
This package is not auto-updated.
Last update: 2025-07-17 21:03:39 UTC
README
This module integrates Tapbuy's checkout experience with Magento 2, enabling A/B testing capabilities for checkout flows and transaction tracking through GraphQL API.
Features
- A/B testing for checkout experiences via GraphQL
- Customizable redirection settings for mobile and desktop devices
- Transaction tracking with order placement events
- Secure communication with Tapbuy API using AES encryption
- Seamless integration with Magento's checkout flow
- Cookie-based session management for A/B test tracking
Installation
Via Composer
composer require tapbuy/module-redirect-tracking bin/magento setup:upgrade bin/magento setup:di:compile bin/magento setup:static-content:deploy -f bin/magento cache:flush
Manual Installation
-
Create the following directory structure in your Magento installation:
app/code/Tapbuy/RedirectTracking/
-
Extract the module contents to this directory
-
Enable the module:
bin/magento module:enable Tapbuy_RedirectTracking bin/magento setup:upgrade bin/magento setup:di:compile bin/magento setup:static-content:deploy -f bin/magento cache:flush
Configuration
- Log in to the Magento admin panel
- Navigate to Stores > Configuration > Tapbuy > Checkout Settings
- Configure the following settings:
General Settings
- Is Tapbuy Enabled: Enable or disable the module
- Is Mobile Redirection Enabled: Enable or disable redirection for mobile devices
- Is Desktop Redirection Enabled: Enable or disable redirection for desktop devices
API Settings
- API URL for Tapbuy: Your Tapbuy API endpoint URL (default: https://api.tapbuy.io)
- API Key for Tapbuy: Your Tapbuy API key (encrypted)
- Encryption Key for Tapbuy: Your Tapbuy AES encryption key (encrypted)
Gifting Settings
- Is Gifting Enabled: Enable or disable the gifting feature
- Gifting URL: Your Tapbuy gifting URL
GraphQL Usage
The module provides a GraphQL query to trigger A/B testing and handle redirects:
Query
query TapbuyRedirect($input: TapbuyRedirectInput!) { tapbuyRedirect(input: $input) { redirect redirect_url message } }
Input Variables
{ "input": { "cart_id": "string", // Required: Guest cart ID or customer cart ID "force_redirect": "string" // Optional: Force redirect parameter } }
Response
{ "data": { "tapbuyRedirect": { "redirect": true, // Boolean indicating if redirect should occur "redirect_url": "https://tapbuy.example.com", // URL to redirect to (or /checkout for standard) "message": "Redirect to Tapbuy." // Descriptive message } } }
Example Usage
// Frontend GraphQL query example const TAPBUY_REDIRECT_QUERY = ` query TapbuyRedirect($input: TapbuyRedirectInput!) { tapbuyRedirect(input: $input) { redirect redirect_url message } } `; const variables = { input: { cart_id: "masked_cart_id_here", force_redirect: null } };
How It Works
-
A/B Test Trigger: When the GraphQL query
tapbuyRedirect
is called with a cart ID, the module:- Validates the cart exists and belongs to the customer (if authenticated)
- Sends tracking data, cookies, and cart information to Tapbuy API
- Receives A/B test variation response
-
Redirection Logic: Based on the API response:
- If
redirect: true
andredirectURL
is provided, customer is redirected to Tapbuy checkout - If
redirect: false
, customer continues with standard Magento checkout - A/B test ID is stored in cookies for tracking
- If
-
Transaction Tracking: When an order is placed:
- Order data is automatically sent to Tapbuy API via the
OrderSaveAfter
observer - Transaction includes order ID, total, payment method, shipping method, and A/B test variation ID
- Order data is automatically sent to Tapbuy API via the
-
Security:
- Cart and session data is encrypted using AES-256 encryption
- API requests include proper headers and authentication
- Sensitive configuration values are encrypted in the database
Cookie Management
The module manages the following cookies:
- tb-abtest-id: Stores the A/B test variation ID (HttpOnly, Secure, 1-day duration)
- Tracks various analytics cookies (
_ga
,_pcid
, etc.) for Tapbuy analysis - Preserves Magento session cookies for seamless integration
API Endpoints
The module communicates with these Tapbuy API endpoints:
POST /ab-test/variation
: Triggers A/B test and gets redirect decisionPOST /ab-test/transaction
: Sends transaction data after order placement
Requirements
- Magento 2.3.x or higher
- PHP 7.3 or higher
- phpseclib3 library for AES encryption
- GraphQL support (included in Magento 2.3+)
Logging
All Tapbuy-related activities are logged to /var/log/tapbuy.log
for debugging and monitoring purposes.
Development Mode
In development mode, SSL verification is disabled for API requests to facilitate testing with local/staging environments.
Support
For support issues, please contact Tapbuy support or create an issue in the repository.
License
This module is licensed under the Open Software License v. 3.0 (OSL-3.0).