Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2012-04-12
1
Medium Priority
?
629 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 1500 total points
ID: 37841281
//try:


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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
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…

722 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