timeinc/tealium

Tealium Implementation for PHP

1.0.0 2016-03-21 17:28 UTC

This package is not auto-updated.

Last update: 2024-11-21 01:07:30 UTC


README

Build Status

This package provides Tealium integration for PHP, handling script generation and Universal Data Object (UDO) control.

Implementations

Installation

Composer

composer require timeinc/tealium

Usage

PHP

<?php

use TimeInc\Tealium\Tealium;
use TimeInc\Tealium\Udo;

$udo = new Udo();

// use $udo->properties to add data to the UDO object
$udo->properties['site'] = 'My Site';

$tealium = new Tealium('org', 'app', $udo, Tealium::TEALIUM_PROD);

Template

To render Tealium onto the page, use the tealium() twig function:

<html>
    <head>
    </head>
    <body>
        <script type="text/javascript">
         var <?php $udo->getName(); ?> = <?php echo (string) $udo ?>;
        </script>
        <script type="text/javascript">
            (function(a,b,c,d){
                a='//tags.tiqcdn.com/utag/<?php echo $tealium->getOrganisation() ?>/<?php echo $tealium->getApp() ?>/<?php echo $tealium->getEnvironment() ?>/utag.js';
                b=document;c='script';d=b.createElement(c);d.src=a;d.type='text/java'+c;d.async=true;
                a=b.getElementsByTagName(c)[0];a.parentNode.insertBefore(d,a);
            })();
        </script>
    </body>
</html>