Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions

variable from google ads only works on page refersh


Reply

326 Views

Avatar
neilos

27 October 2012 at 12:53am Community Member, 19 Posts

Hi,

I am trying to get a variable from various google location ads to change the phone number depending on the ?number=xxx from the ad.

The number displays a default value unless the page is refreshed, then the variable is displayed.

Is there a better way of doing this that will display the variable number without the need for a page refresh?

In page.ss

<% if phonenumber %>$phonenumber <% else %>0800 xxx xxx<% end_if %>

In page.php

public function Phonenumber() {
    include('defines.php');
return strip_tags (Session::get ('number'));
}

And defines.php

<?php

ob_start();
if (!isset($_SESSION)) {
@session_start();
}
if (!isset($_SESSION['number']))
{
$phonenumber = $_GET['number'];
$_SESSION['number'] = $phonenumber;
    }

ob_end_flush();
?>