TID php script and Google javascript

2 replies
Hi everyone... I am hopeful that someone can help me out with this sticky problem...

Here is the scoop:

I had to create some landing pages with php script to capture the "Clickbank TID" from the Google Content Ads I'm running. And then I created clickable links that go directly to the redirect page with the php script to pass on the TID straight to the merchant page so I can identify which Google Content Adgroup was responsible for making the sale.

At the same time I wanted to use Google's Analytics as well as Google's Website Optimizer which is the main reason why I used the redirect page. I'm using it for the "goal" page.

And so far, so good. The TID has been picked up correctly on the merchant's page. However... (you knew this was coming...)

The Google javascript doesn't seem to work...

It seems that the php script redirects before the Google javascript has a chance to register a hit on the page.

Can anyone suggest a way around this?

I really appreiate it,

John
#google #javascript #php #script #tid
  • Profile picture of the author Neil Morgan
    John

    Without seeing your page code, it's difficult to know for sure what the problem is.

    The first thing I would be looking at is the order that the various bits of tracking code appear in your page.

    For example, if the redirect code is before the Analytics code then clearly the Anatlytics code won't be run.

    Just an initial thought.

    Cheers,

    Neil
    Signature

    Easy email marketing automation without moving your lists.

    {{ DiscussionBoard.errors[311079].message }}
  • Profile picture of the author Andrew E.
    Hi John,

    PHP is a server runtime language, meaning it will always run before HTML is even seen by the server.

    Any php redirect will ALWAYS work before javascript.

    Right now, there is not one html tag getting to the browser before the jump happens.

    Instead of using a PHP redirect on your google code page, use a meta tag redirect, and set it to 0 seconds. This will render javascript and/or any pixel tracker, and still allow a redirect to happen.

    Here is some example code for you. The variables won't be right, but you will get the idea.

    HTML Code:
    <?php $tid = $_GET['tid']; ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <META  http-equiv="refresh"  content="0;URL=http://www.yoursite.com/landingpage.php?tid=<?php print $tid; ?>">
    <head>
    <title>Redirect Page</title>
    </head>
    
    <body>
    </body>
    <--! Google JS can go here-->
    </html>
    {{ DiscussionBoard.errors[311653].message }}

Trending Topics