PHP code example of anthonypauwels / datalayer

1. Go to this page and download the library: Download anthonypauwels/datalayer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

anthonypauwels / datalayer example snippets


Anthonypauwels\DataLayer\Laravel\ServiceProvider::class,

'DataLayer' => Anthonypauwels\DataLayer\Laravel\DataLayer::class,


return [
    'gtm_id' => 'GTM-XXXXXXXX'
];

use Anthonypauwels\DataLayer\DataLayerHandler;
use Anthonypauwels\DataLayer\SessionHandler;

$datalayer = new DataLayerHandler( 
                new SessionHandler(), 
                'GTM-XXXXXXXX'
            );

use Anthonypauwels\DataLayer\Laravel\DataLayer;

DataLayer::push('foo', 'bar');

DataLayer::push('foo', 'bar');

DataLayer::pushArray([
    'user_name' => 'John Doe',
    'age' => '42',
    'country' => 'Belgium',
]);

DataLayer::publish();

DataLayer::noScript();

DataLayer::publish(['init' => false, 'script' => false, 'clear' => false]);

DataLayer::pushData([
    'user_name' => 'John Doe',
    'age' => '42',
    'country' => 'Belgium',
]);

DataLayer::load();

DataLayer::save();

DataLayer::clear();

DataLayer::getData();

DataLayer::init();

DataLayer::script([$gtm_id = null]);

DataLayer::noScript([$gtm_id = null]);

DataLayer::dd();