Forum Moderators: open

Message Too Old, No Replies

How to create a pop up at exit of site & not page?

I know how to create one for the exit of a web page...

         

phillypleez

2:19 am on Dec 2, 2001 (gmt 0)

10+ Year Member



Can you refer me to a an example of code that will open a pop up window after a person leaves the site? I know how to make one when the person leaves a specific page but this is a problem because if they just go to another page of my site they will get that pop up everytime. I suppose the code needs to have cookies. Any info will be much appreciated.

tedster

10:08 am on Dec 2, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One way to approach this without cookies would involve modifying every internal link on your site. Here's the logic behind the code.

_____________________

1) From the HEAD section of every page, set some variable (let's call it leaving) to "true".

2) Also from the HEAD section, define your popup function so that it only launches a window after testing to see if (leaving = true).

3) Now include the onClick event handler in every internal link on the site, and set leaving = false. So, all your site's internal links should now look something like this:

<a href="stillmypage.html" onClick="leaving = false">Link Text</a>

4) Finally, within the BODY tag of each page, use the onUnload handler to call your popup function.

If an internal link was clicked, then the variable will be false -- and the popup window will not launch. However, if the page is unloading but an internal link was not clicked, the variable will be true and the popup will launch.
_______________

This approach fails if an internal URL is typed into the location bar, but that's not very likely. There is one major flaw I can see — using the Back button will trigger the popup window every time, whether the visitor is going "back" to one of your pages or not.

SmallTime

10:39 am on Dec 2, 2001 (gmt 0)

10+ Year Member



Interesting approach tedster - I was still wondering what possible good reason there could be for a pop up on leaving a site - the reasons I come up with fall under "annoy the user so they don't come back" catagory.

tedster

11:31 am on Dec 2, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Small Time, I've heard of two uses for an exit pop-up that some claim to show decent results.

One is for a short survey of some kind. Using the exit pop-up up gives a more statistically valid set of results, or so this White Paper I was reading claimed. At least it eliminates some of the biases that other methods introduce into the sample.

The second use (some affiliate programs tout this) is to use the exit popup to pitch one last "deal". These programs claim some conversions on exit, and if the prospect was already leaving, any conversion at all is thought to be an improvement.

But the annoyance factor (and it's obviously there) would be pretty hard to measure. Maybe you could cookie visitors when the popup loads and see how many return. Then use the same JavaScript logic to place an exit cookie but no popup, and see how many of those return.

I've never seen any data on a scheme like that, however.

txbakers

4:54 am on Dec 3, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I get annoyed with the exit popups for sure, but I can see and have seen some valid uses. When I close a WebEx session I get a popup asking for feedback on the help session.

kapow

6:16 pm on Dec 6, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That seems like an elegant solution Tedster.
Is it possible to set the 'leaving' variable when someone clicks the back button?

Is there some javascript that does this?

IanKelley

10:31 pm on Dec 7, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Tedster's solution would work (even if the surfer left using the back button, bookmark, etc..) if you assigned the 'leaving' variable to true as default and then assigned it to false only on internal links.

tedster

10:56 pm on Dec 7, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>> Is it possible to set the 'leaving' variable when someone clicks the back button?

I can't think of a way.

Even if we could, we would want to set 'leaving = false' if the Back Button destination was still on the site, and 'leaving = true' if the destination was off site. And that kind of knowledge is not available to JavaScript, for pretty big security reasons.

Cadet Cheapstakes

9:13 pm on Dec 17, 2001 (gmt 0)



I got round this problem very easily in the end.

Use a blur console that opens the pop up behind your page. It will stay there until manually closed down. The blur javascript is very easy.

<script language="JavaScript">
<!-- Hide script from older browsers
if(navigator.appName.indexOf("WebTV")==-1){
myWin=open('','winin','toolbar=0,menubar=0,scrollbars=0,status=0,resizable=0,width=450,height=140');
myWin.blur();
myWin.location = 'http://whatever.htm';
}
// end hiding contents -->

Stick that in between Head and Head and you have a pop up that doesnt intrude to much on the surfers experince.

Problem: You can only use one (On each page?) - but more than one pop up is a waste. Also many surfers are turning off their javascipts - so the days of the pop ups are probably numbered.

Finally, most people are oblivious to pop ups - I for one rarely read them. I close them before they even are fully "popped up".

Hope this helps.

By the way can you use this on more than one page - so you have a blur pop up on each page. I dont have time to try it.

Regards

tedster

4:51 pm on Jan 20, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think I've got another purpose for this scheme -- other than launching pop-ups. One of my clients runs a newsletter where the main page is online. They want an easy measure of how many people click the newsletter links to explore further into their site.

By using this "leaving variable" scheme to download a dedicated 1x1 gif (just cache it with a "new Image" script, not render it) I think we can compare newsletter pageviews to gif downloads and easily see how persuasive the newsletter is in drawing people further into the site.

joshie76

11:21 am on Jan 21, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is another way to do this (Tedsters is a solid approach, this is just an alternative)...

Create a frameset as the homepage of your site with two frames. One frame will be your real homepage. The other is a static page used to maintain session state and is invisible (set the frame width or height to 0%)

In the session state page have the body onUnLoad event fire your pop up.

PROS: Easier to implement.

CONS: Need to be sure that visitors will always enter via the frameset page. This is fine for something like an intranet application but can be problematic for a website where people may clickthrough from a search engine direct to your real homepage etc...

This is a useful technique for web application development as you can also store various session state variables in the hidden frame. Particularly useful if you're developing for a web farm (where there can be serious problems with server-side session state variables).

shady

12:29 pm on Oct 20, 2002 (gmt 0)

10+ Year Member



Hi Cheapstakes

If you wish to have a single popup which is triggered from multiple pages, you can put this code on as many pages as you like.
If you want multiple popups, simply change the second parameter to "something else" to popup different windows.

Hope that answers the question, and thanks for the posting. I used the use the Joshies frame method, but yours is more appropriate for my application. I'll post up the results after a few days.

txbakers

4:12 pm on Oct 20, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Funny this should come back to the top - I'm fighting the issue right now.

To add another CON to joshie's approach - a big CON - with a frameset, anytime the user clicks REFRESH, it takes them back to the frameset page, not the page they are on. If there is a work around for this one, I'd love to use it, because that was the best solution for me so far.

I'm going to try the popunder approach next.

instand1

4:56 pm on Oct 20, 2002 (gmt 0)

10+ Year Member



Are you not afraid that the pop up window might give you some punishment by Google? Or are you not relying on your ranking in Google?

txbakers

6:07 pm on Oct 20, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, I don't care about my Google ranking. I don't rely on any search engine at all. I do all my own marketing. Anything that comes from a search engine is strictly gravy.

shady

6:46 pm on Oct 20, 2002 (gmt 0)

10+ Year Member



Does anyone know for a fact that a popup will affect your google ranking and if so, would it affect the site as a whole (assuming the popup is on the default page) or just the offending page?

shady

3:14 pm on Oct 22, 2002 (gmt 0)

10+ Year Member



I have use Cadet Cheapstakes implementation of the Hidden Popup and found that on IE5 the popup actually comes up in front of the main page, not behind.
Presumably, this is simply a bug in IE5, as other browsers seem to function correctly. Does anybody have a solution for this?

ikbenhet1

9:30 pm on Nov 14, 2002 (gmt 0)

10+ Year Member



try window.focus(); in stead of window blur, i assume that will work also in ie 5.x

caine

9:39 pm on Nov 14, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



drawing back to the why off it, if your looking at unique customers, that come and visit, buy if there interested leave and never come back then the exit poup is acceptable, except to people who don't like them at all.

However if you are looking at returning customers, then forget about popups on exit. better using SSI's on relevenat pages to the search for daily deals as such, otherwise if you have a high return rate you will annoy whoever.