[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Javascript tracker not functioning on PHP page

Posted on 2011-10-07
7
Medium Priority
?
280 Views
Last Modified: 2012-05-12
I am trying to use a PHP file to redirect visitors to a page outside my web domain when they click a certain menu button on my web page.  Since I can't insert tracking code on a site outside my domain, this PHP redirect page is intended to record visitor activity, using javascript tracking code.  The redirect function works, but the tracking code is not working.

 I have experimented with other methods to accomlplish this, and encountered flaws with each of them. The javascript window.open function triggers popup blockers;  the window.location function results in an active Back button, under IE and Safari, when the browser arrives at the outside site. The Back button only reloads the same page, which will irritate visitors;  and a meta refresh page which also produces the unwanted Back button.  I am hoping to make the javascript tracker work with this PHP page.   TripAdvisor.php
0
Comment
Question by:ddantes
  • 3
  • 2
  • 2
7 Comments
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 36934995
None of the HTML or javascript will ever execute on that page because that page will never be seen by browser.  The PHP header redirects the browser before it ever sees your other code.

You might as well make it a pure PHP page and do the tracking in PHP before you do the redirect.
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36934998
Actually, you should just get an error since you put HTML before the header...
0
 
LVL 8

Expert Comment

by:Ahmed Merghani
ID: 36935508
As DaveBaldwin said, it is better to use pure PHP. If you wish to get some info about the visitor, like the browsero or OS ..etc, you can use URL user agent.
$_SERVER['HTTP_USER_AGENT']

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:ddantes
ID: 36936396
Thank you for your comments.  Can you convert the code on the page I uploaded to pure php?  This is my first php project.
0
 

Author Comment

by:ddantes
ID: 36936651
After my last post, I discovered that coding a pure php page may require considerable time and effort.  So if my request for assistance with this item is inappropriate, please excuse me.
0
 

Author Comment

by:ddantes
ID: 36940767
I found a programmer who recommended an Ajax solution to this dilemma.  The redirect page now loads the two javascript tracking codes before loading the outside web content in an Iframe.  The redirect works, and the Extreme Tracking works.  But there is some issue with Google Analytics.  When I access in-page analytics, there is a message: "we could not access your web page, www.mauitradewinds.com/Ajax/TripAdvisor.php."  However, the redirect page, TripAdvisor.php, resides in the root directory.  There is no Ajax directory.  Please examine the code in the embedded file and let me know what it needs in order to work with Google Analytics. TripAdvisor.php
0
 
LVL 8

Expert Comment

by:Ahmed Merghani
ID: 36940867
Try to change the settings in Google in-page analytics to "www.mauitradewinds.com/TripAdvisor.php
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses
Course of the Month20 days, 5 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question