How to add PHP server side variables as UDO variables to Tealium

If your website is built in PHP and you are using Tealium products then you might have the need to add server side PHP variables to your data layer so you can use them within TealiumIQ and/or AudienceStream.

The first thing you have to do is to copy the PHP variable values into javascript variables that are part of the utag_data layer:

<script type="text/javascript">
var utag_data = {
user_id : '<?php echo $userRec['id'] ?>',
user_name : '<?php echo $userRec['username'] ?>',
user_num_visits : '<?php echo $userRec['num_visits'] ?>',
user_membership : '<?php echo $userRec['membership'] ?>'

Once this has been implemented you will be able to see the variables on the client side. With the Tealium Web companion you can simply see them when you extend the Javascript category under the Data tab.

web companion

Adding php variables to utag_data

Click on the little Add-buttons to the left of the variables to add them to the Queue that is shown at the bottom of the Web companion. Once all variables have been added click on the queue. Then click the save button. A popup window will request your username and password for TealiumIQ. Once entered the web companion will add the new variables to your data layer and you will see them inside the data layer tab of TealiumIQ.

php variables in data layer

php variables in data layer

Roland Oberdorfer is a Managing Director and Co-Founder at SiteOlytics Inc. Prior to his current role Roland was the CTO of HP’s consumer direct organization and the General Manager for Web and eCommerce at NIVIDIA. You can find him on Google+ and on Facebook.



More from our blog

See all posts