PowerMan2015
PowerMan2015

Reputation: 1418

Number tracking implementation

I'm about to implement my own tracking pixel in order to get visitor information from my marketing sites.

In addition to the above I need to pass some information back (phone number) to the visitor and change the content of a specific span class tag on the site.

I understand the process of passing information in the direction of my analytics server but not the other way around .

I'm hoping to run this with php on the sever sites and JavaScript on the client side

I know it's possible as a supplier of ours simply gives us a tracking code which is only a few lines long and we supply our class tag.

Upvotes: 0

Views: 54

Answers (2)

Mattia Merlini
Mattia Merlini

Reputation: 663

You can use Ajax as you can see in this example.

The main part is

var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() 
{
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) 
    {
        document.getElementById("txtHint").innerHTML = xmlhttp.responseText; /*retrieve the phone number*/
    }
};

And in the PHP part simply echo your desired phone, based on what you queried with you tracking pixel:

<?php
    $customer_id = $_GET['customer_id'];

    // Do stuff

    $phone_number = myPersonalQueryFunction($customer_id);

    echo $phone_number; // or exit($phone_number)
?>

Upvotes: 1

user6101582
user6101582

Reputation:

Tracking pixels only send data from the user to the server. Updating content on your site should be done via XMLHttpRequest, which allows the server to return a response that can be used in client side javascript.

Upvotes: 1

Related Questions