Solved

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

Posted on 2012-04-12
1
597 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Jquery if else not working ... WHY? 5 24
How do I speed up this PDO query 4 13
php hashing methods 3 10
php output utf-8 problem 6 19
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

763 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