Download the PHP package marshmallow/marketing-data-tracker without Composer
On this page you can find all versions of the php package marshmallow/marketing-data-tracker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download marshmallow/marketing-data-tracker
More information about marshmallow/marketing-data-tracker
Files in marshmallow/marketing-data-tracker
Package marketing-data-tracker
Short Description Parse and store marketing parameters like gclid, utm_*, and adid, and automatically attach them to user conversions or models in Laravel.
License MIT
Homepage https://github.com/marshmallow-packages/marketing-data-tracker
Informations about the package marketing-data-tracker
๐ฏ Laravel Marketing Data Tracker
Comprehensive Marketing Attribution & UTM Parameter Tracking for Laravel
Track, store, and analyze marketing attribution data from Google Ads, Facebook, TikTok, LinkedIn, and 10+ other advertising platforms in your Laravel application. Automatically capture UTM parameters, click IDs, and conversion data to understand your marketing performance and ROI.
Perfect for e-commerce sites, SaaS applications, and any Laravel project that needs comprehensive marketing attribution tracking.
โจ Features
๐ Multi-Platform Support - Google Ads, Facebook/Meta, TikTok, LinkedIn, Twitter, Pinterest, Microsoft Ads, Reddit, Snapchat, and more
๐ฏ Intelligent Click ID Tracking - Automatically detect and prioritize gclid, fbclid, ttclid, msclkid, and other platform-specific identifiers
๐ UTM Parameter Management - Complete UTM tracking with automatic parameter extraction and storage
๐ Conversion Attribution - Link conversions back to their original marketing source with full attribution data
๐ช Advanced Cookie Support - Track 60+ marketing cookies across all major advertising platforms
โก Zero Configuration - Works out of the box with sensible defaults, fully customizable
๐ก๏ธ Privacy Compliant - Built-in GDPR support with consent management and data export
๐ฑ Mobile Attribution - iOS 14.5+ support with gbraid and wbraid tracking
๐จ Laravel Nova Integration - Beautiful admin interface for viewing marketing data
๐ Quick Start
Installation
Install via Composer:
Publish and run migrations:
Basic Setup
1. Add the trait to your models:
2. Add the middleware to your web routes:
On Laravel 11+ register it in bootstrap/app.php:
On Laravel 10, add it to the web group in app/Http/Kernel.php:
3. Track marketing data on user registration:
That's it! ๐ The package will now automatically track marketing parameters from all major advertising platforms.
๐ Platform Support
Enhanced Multi-Platform System
The package now features a comprehensive platform management system supporting 12+ advertising platforms with configurable parameters, cookies, and tracking templates.
Supported Advertising Platforms
| Platform | Click ID | UTM Source | Custom Parameters | Status |
|---|---|---|---|---|
| Google Ads | gclid, gbraid, wbraid |
google |
20+ ValueTrack parameters | โ Enhanced |
| Meta/Facebook | fbclid |
facebook, meta |
Dynamic campaign parameters | โ Enhanced |
| Microsoft Ads | msclkid |
bing, microsoft |
UET tracking parameters | โ Enhanced |
| LinkedIn Ads | li_fat_id |
linkedin |
Professional network parameters | โ Enhanced |
| Twitter/X Ads | twclid |
twitter, x |
Social media parameters | โ Enhanced |
| Pinterest Ads | epik |
pinterest |
Visual platform parameters | โ Enhanced |
| TikTok Ads | ttclid |
tiktok |
Short-form video parameters | โ Enhanced |
| Reddit Ads | rdt_cid |
reddit |
Community platform parameters | โ Enhanced |
| Snapchat Ads | sscid |
snapchat |
Mobile-first parameters | โ Enhanced |
| Amazon DSP | maas |
amazon |
E-commerce advertising | โ Enhanced |
| TradeTracker | ttid |
tradetracker |
Affiliate network tracking | โ New |
| Email Marketing | mc_cid, mc_eid |
email |
Campaign tracking | โ New |
Platform Configuration
Each platform can be individually enabled/disabled and configured:
Automatic Parameter Detection
The package automatically detects and stores 175+ marketing parameters:
- Standard UTM:
utm_source,utm_medium,utm_campaign,utm_term,utm_content - Google Ads:
gclid,gbraid,wbraid,mm_campaignid,mm_adgroupid,mm_keyword, etc. - Facebook:
fbclid,campaignid,adsetid,adid,placement,site_source - Email Marketing:
mc_cid(Mailchimp),utm_email,list_id - Affiliate Programs:
ref,affiliate_id,partner_id
๐ฏ Usage Examples
Basic Marketing Attribution
Advanced Click ID Management
The package now features priority-based click ID detection with configurable extraction and cookie support:
Click ID Priority Configuration
E-commerce Conversion Tracking
Enhanced e-commerce tracking with Google Tag Manager format and multiple platform support:
E-commerce Configuration
Campaign Performance Analysis
โ๏ธ Configuration
Publish the configuration file:
Platform-Specific Configuration
Cookie Consent Management
Consent handling lives under the cookie_management key, which also groups
cookies into analytics, advertising, and functional buckets:
When
auto_register_exceptionsis enabled (the default), the package automatically adds all configured marketing cookies to Laravel'sEncryptCookiesexceptions so they can be read in plain text.
๐ง Advanced Features
Marketing URL Builder
NEW: Fluent URL builder with platform-specific templates and ValueTrack parameter support:
URL Builder Features
- โ Platform Templates: Pre-configured URLs for Google Ads, Meta, Microsoft, LinkedIn, Twitter, TikTok, Pinterest
- โ ValueTrack Support: Full Google Ads ValueTrack parameter integration
- โ Dynamic Parameters: Meta/Facebook dynamic parameter placeholders
- โ Fluent Interface: Chainable methods for easy URL construction
- โ Parameter Filtering: Automatic filtering of empty/null values
- โ Template System: Use tracking URL templates from configuration
Event-Driven Architecture
NEW: Comprehensive event system for marketing data lifecycle tracking:
Event Configuration
Laravel Nova Integration
๐จ Platform-Specific Setup
Google Ads Configuration
Add to your Google Ads account-level tracking template:
Facebook Ads Configuration
Use Facebook's URL parameters in your ads:
Server-Side Tracking Setup
For accurate attribution, configure server-side tracking:
๐๏ธ Architecture
Database Schema
The package creates a flexible marketing data storage system:
Privacy & GDPR Compliance
- Consent Management: Built-in cookie consent handling
- Data Anonymization: Automatic PII detection and masking
- Data Export: GDPR-compliant data export functionality
- Retention Policies: Configurable data retention periods
๐ Analytics Integration
Google Analytics 4
Facebook Conversions API
Forward conversions to the Facebook Conversions API by listening for the
ConversionTracked event and using the attribution data it carries:
Custom Analytics Platforms
๐งช Testing
Testing Marketing Attribution
๐ Performance
- Minimal Database Impact: Marketing data is stored as JSON on a single related row per model.
- Lazy Loading: The
marketing_datarelation is loaded only when accessed. - Path Filtering: Use the
ignore_pathsconfig to skip parsing on routes that never carry marketing parameters. - Batch Writes: Use
setMarketingDataBatch()on a model to write multiple parameters in one operation.
๐ ๏ธ New Advanced Features
Automatic Model Observation
NEW: Automatic UTM data capture and click ID detection:
Cookie Management System
NEW: Advanced cookie tracking with consent management:
Platform Management Service
NEW: Centralized platform configuration management:
๐ API Reference
Enhanced HasMarketingParameters Trait
| Method | Description | Example |
|---|---|---|
setUtmSourceData() |
Capture marketing parameters | $user->setUtmSourceData() |
getPrimaryGoogleClickId() |
NEW: Get Google click ID with priority | $user->getPrimaryGoogleClickId() |
primary_click_id |
Get highest priority click ID | $user->primary_click_id |
platform_name |
Get platform name | $user->platform_name |
detectPlatformFromMarketingData() |
Detect advertising platform | $user->detectPlatformFromMarketingData() |
marketing_parameter_list |
Get formatted parameters | $user->marketing_parameter_list |
MarketingUrlBuilder
| Method | Description | Example |
|---|---|---|
googleAds() |
Build Google Ads URL | MarketingUrlBuilder::googleAds($url, $campaign) |
metaAds() |
Build Facebook Ads URL | MarketingUrlBuilder::metaAds($url, $campaign) |
microsoftAds() |
NEW: Build Microsoft Ads URL | MarketingUrlBuilder::microsoftAds($url, $campaign) |
linkedInAds() |
NEW: Build LinkedIn Ads URL | MarketingUrlBuilder::linkedInAds($url, $campaign) |
withUTM() |
Add UTM parameters | $builder->withUTM($params) |
withGoogleValueTrack() |
NEW: Add ValueTrack parameters | $builder->withGoogleValueTrack() |
withPlatform() |
NEW: Add platform-specific params | $builder->withPlatform('google_ads', $params) |
New Services & Events
| Service/Event | Description | Example |
|---|---|---|
PlatformManager |
NEW: Platform configuration management | $manager->getEnabledPlatforms() |
CookieManager |
NEW: Cookie tracking with consent | $manager->getCookieValues($request) |
MarketingDataCreated |
NEW: Marketing data creation event | Event::listen(MarketingDataCreated::class, ...) |
ConversionTracked |
NEW: Conversion tracking event | Event::listen(ConversionTracked::class, ...) |
ClickIdDetected |
NEW: Click ID detection event | Event::listen(ClickIdDetected::class, ...) |
New Traits
| Trait | Description | Example |
|---|---|---|
TracksConversions |
NEW: Conversion tracking functionality | $model->trackLeadConversion(50.00) |
TracksEcommerceEvents |
NEW: E-commerce event tracking | $product->trackViewItem() |
๐ Upgrading from v1 to v2
Migration Overview
Version 2.0 introduces major new features while maintaining 100% backward compatibility. Your existing code will continue to work without any changes, but you can opt-in to enhanced features for improved functionality.
Step 1: Update the Package
Step 2: Publish New Configuration (Optional)
To access new features, publish the updated configuration:
โ ๏ธ Important: This will overwrite your existing config. Back up your current configuration first if you have custom settings.
Step 3: Enable New Features (Optional)
The new configuration includes several opt-in features. Enable them as needed:
Enable Enhanced Platform Support
Enable Click ID Management
Enable Events (for Analytics Integration)
Enable Auto-Observation (Advanced)
Enable Conversion Tracking
Enable E-commerce Tracking
Step 4: Update Your Code (Optional)
Your existing code will work without changes, but you can enhance it with new features:
Enhanced Click ID Access
Add New Traits for Enhanced Functionality
Use New URL Builder
Implement Event Listeners
Step 5: Test Your Implementation
After upgrading, verify everything works correctly:
Test Existing Functionality
Test New Click ID Priority
Test Platform Detection
Migration Checklist
- [ ] Backup Configuration: Save your current
config/marketing-data-tracker.php - [ ] Update Package: Run
composer update marshmallow/marketing-data-tracker - [ ] Publish Config: Run publish command if you want new features
- [ ] Enable Platforms: Configure the platforms you use
- [ ] Enable Features: Turn on click ID management, events, etc. as needed
- [ ] Update Models: Add new traits if you want conversion/e-commerce tracking
- [ ] Test Functionality: Verify existing UTM tracking still works
- [ ] Test New Features: Verify new click ID priority and platform detection
- [ ] Monitor Events: Check that events fire correctly if enabled
- [ ] Performance Test: Ensure no performance degradation
Common Migration Issues
Issue: Configuration Override
Problem: New config overwrites custom settings Solution: Merge your custom settings with the new configuration structure
Issue: Events Not Firing
Problem: Events enabled but listeners not receiving them
Solution: Ensure 'events' => ['enabled' => true] and check listener registration
Issue: Platform Not Detected
Problem: Platform detection returns null
Solution: Ensure the platform is enabled in the new platforms configuration
Issue: Click IDs Not Prioritized
Problem: getPrimaryGoogleClickId() returns null
Solution: Enable click ID management: 'click_id_management' => ['enabled' => true]
Getting Help
If you encounter issues during migration:
- Check Configuration: Ensure new config sections are properly configured
- Review Logs: Look for error messages in Laravel logs
- Test Incrementally: Enable one feature at a time to isolate issues
- Fallback: Disable new features if needed - v1 functionality will still work
What Stays the Same
โ All existing methods work exactly as before โ Database structure remains unchanged โ UTM parameter capture works identically โ Laravel Nova integration continues to work โ Basic click ID detection functions as before
What Gets Better
๐ Enhanced click ID priority with configurable extraction ๐ 12+ platform support with individual controls ๐ Advanced cookie tracking with consent management ๐ Event-driven architecture for analytics integration ๐ Conversion & e-commerce tracking with attribution ๐ URL builder for campaign management ๐ Wildcard pattern matching for flexible parameter capture
๐ค Contributing
We welcome contributions! Please see CONTRIBUTING.md for details.
Development Setup
๐ Changelog
Please see CHANGELOG for more information on what has changed recently.
๐ Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
๐ก Use Cases
E-commerce Attribution
Track customer acquisition costs, measure ROAS, and optimize ad spend across platforms.
SaaS Conversion Tracking
Monitor trial-to-paid conversion rates by marketing channel and campaign.
Lead Generation
Attribute leads to their original marketing source for accurate ROI calculation.
Content Marketing
Track which content pieces drive the most valuable conversions.
Multi-Touch Attribution
Understand the complete customer journey across multiple touchpoints.
๐ Why Choose This Package?
โ Battle-Tested - Used in production by hundreds of Laravel applications
โ Comprehensive - Supports more platforms than any other Laravel marketing package
โ Developer Friendly - Clean API, excellent documentation, and Laravel conventions
โ Performance Optimized - Minimal overhead with intelligent caching
โ Privacy Compliant - Built-in GDPR support and consent management
โ Actively Maintained - Regular updates and new platform support
๐ Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: [email protected]
๐ License
The MIT License (MIT). Please see License File for more information.
๐ Credits
- Marshmallow - Package development and maintenance
- All Contributors - Community contributions and feedback
Made with โค๏ธ by the Marshmallow team
Star โญ this repo if you find it helpful!
All versions of marketing-data-tracker with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^10.0||^11.0||^12.0|^13.0