Solved

Javascript - Onclick, open new window in background + Google Analytics Outgoing Link Tracking

Posted on 2012-04-12
1
587 Views
Last Modified: 2012-04-24
Hello everyone,

I currently have a page where users enter data in a field and when they click on 'execute', the system runs an internal script and presents them the results.

When 'execute' is clicked, an advertisement window pops up.

Here is what I am after:

1) The popup window to be in the background so it doesn't pop in front of the current window
2) Add Google Analytics outgoing Link Tracking code so I can track through Google Analytics how many people got the popup advertising window.

For the first requirement, here is the portion of the file which performs the popup function and needs to be modified according to my first request (1):
<?php
  if ($ok) {?>
<script type="text/javascript">
window.onload=function() {
  var w = window.open("http://advertising_website","_blank");
  if (!w) alert('Sorry, you have blocked popups')
}
</script>
<?php } ?>


For the second requirement, here is the GA code that I'd normally place in a hyper link within my php files. This needs to be embedded so onclick (when the person clicks on 'execute', its run:

Analytics Outgoing Link Tracking
<a onclick="javascript:_gaq.push(['_trackEvent','Home','click','http://customer_website.com']);" href="http://customer_website.com" target="_blank"> Vist now!</a>


Please let me know if more information is required.

Thank you.
0
Comment
Question by:kosmas
1 Comment
 
LVL 20

Accepted Solution

by:
Proculopsis earned 500 total points
ID: 37841281
//try:


var w = window.open("http://time.gov","_blank");
w.blur();
window.focus();
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

911 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now