Skip to content

V1.0.9: Autoparsing

Choose a tag to compare

@aawnu aawnu released this 19 Nov 19:17
· 285 commits to master since this release
a97aa9c

Add import from array to event or item, making it possible to prebuild events on frontend before passing to backend.

axios.post('/api/ga4', {
    addToCart: {
        currency: 'EUR',
        value: 13.37,
        items: [
            {
                'item_id': 1,
                'item_name': 'Cup',
                'price': 13.37,
                'quantity': 1
            }
        ]
    }
})
use AlexWestergaard\PhpGa4\Analytics;
use AlexWestergaard\PhpGa4\Event;

$addToCart = Event\AddToCart::fromArray($_POST['addToCart']);

Analytics::new($measurementId, $apiSecret)->addEvent($addToCart)->post();

What's Changed

  • Add static fromArray() method to Events and Items by @aawnu in #22

Full Changelog: v1.0.8...v1.0.9