Solved

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

Posted on 2012-04-12
1
584 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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 dynamically set the form action using jQuery.
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…

744 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

13 Experts available now in Live!

Get 1:1 Help Now