GWO: Using trigger Exit page to start test variation - javascript

Our marketing team is asking if it is possible to run a test on our site where the variations are shown based on a page exit, versus a page load. I said I could try to see if I could handle it with custom code but I would love to use something already existing. I don't have the knowledge already to trigger a page exit myself and that's what I need to find out.
Scenario: The user would load the page, GWO would decide there which variation to show on load, and when the user "exits" then variation 1 would load a popup. The popup would have a link within it and conversion would be based on the user clicking the link. An exit would be defined here as anyone leaving the domain via the back button, closing the browser, or typing in another address into the address bar. An exit here is not specifically the page but the entire domain itself. Variation 1 of the test would only be served on roughly 10 pages (our of thousands on our retail site).
I somehow think that Google Analytics defines exit already and wonder if I couldn't piggy-bank that trigger? Does GWO have something similar? I don't think it's feasible or logical for our site to track if variation 1 user leaves the domain from any point, so perhaps only tracking exit if they were served variation 1 and only from the same page they got served variation 1.
So I know that's a loaded question, but has it been before within a test? Any easy way to handle it? Thanks in advance!

First off, giving a popup when a visitor is trying to leave your site is horrible UX. It is something that absolutely everybody hates, absolutely no exceptions, period. And...trying to find out which variation of an "exit link popup" works best is like trying to find out which method of torture people like most. So my very first advice to you is I strongly recommend you push back to your Marketing team about this, they should know better...if they are actually suggesting this then maybe they need to be (re)trained (or fired...) Just sayin'...
But anyways... Ga officially states there is no auto-exit link tracking. I know that for the most part, GA determines exit links on current ping vs. next ping (or lack of), but my experience from poking at ga.js leads me to believe they do indeed to some degree have exit link / page unload tracking tucked away in there...
But rather than trying to reverse engineer ga.js to see if it's even possible to tap into something that may or may not really be there, if you have jQuery or similar framework on your page (which most sites do, and if you don't, just include it on your test page(s) easy enough), you can use jQuery's .unload() to get it to trigger as you want.
edit: One thing you said:
An exit here is not specifically the page but the entire domain itself.
Okay that's one "gotcha" that is not possible. You can write code to compare the current URL to the target URL if the visitor clicks on a link on your page, but javascript does not allow for you to access the new URL typed into the address bar, nor does it allow you to see the previous URL in the history (like if user clicks the back button) - both of these are browser security features - so there is no way for you to know 100% if the visitor is exiting your domain.
Tracking tools like GA get around this for some of their data, by having a "session" timer keep track of last activity by the visitor. If the session times out, then the last ping submitted gets the extra data for exiting your site, like "last page of visit", bounce rate numbers, etc.. (though it will not show where the visitor actually went, for reasons listed above)

Related

Is it possible to create a button that opens a specified website in a new tab and closes the current one?

I am creating a WordPress website for a client. This website offers support for victims of abuse, and my client wishes for a "panic" button on the website that, when clicked, either:
a) sends the user to a specified website (for example google.com) and then erases the history of the Back button
b) opens a specified website in a new tab (which eliminates the Back button issue) and then closes the current one.
I tried adding a simple button like this:
<button onclick="window.close();">Close</button>
But then I get this in the console:
[Warning] Can't close the window since it was not opened by JavaScript
If this is not possible to do by using Javascript, are there any other ways I can go about doing it?
Not possible.
The problem you're up against is that the browser doesn't allow Javascript to control things like opening and closing tabs, and rightly so. A web page really shouldn't be able to access or control things outside of its tab, this is a concept called sandboxing. Web pages are free to play in their own sandbox, but aren't allowed to know about or change things outside their sandbox. "Browser history" and "Other tabs" are both outside your web page's sandbox.
It's not that this is impossible in JavaScript, it's going to be impossible for any well designed browser, full stop. It's not a question of what technology you could use to accomplish this, it's a behavior that's explicitly prohibited by design. If you could do this on a major browser, you would probably be offered a bug bounty. Imagine what a malicious actor could do with the ability to modify the history in the back button, or to close other tabs.
Beyond that, I'm concerned about the approach that your employer is taking. Abusers are often more technically savvy than their victims, and a "panic button" like that won't even affect the browser's overall history, let alone defeat any advanced monitoring like spyware, or a fancy router's DNS monitoring. Victims of abuse should be discouraged from using devices or networks they believe are compromised and should seek help through trusted and secure channels of communication. I'm troubled that any sort of "panic button" functionality could create a false sense of security for a user that is not security-savvy.

Chrome extension that would update facebook group page without reloading page

I have been thinking about this but can't figure out due to lack of familarity with how actually facebook is designed to work. If you can help and point me in right direction that would be helpful.
Problem: If you are at a group page and someone post a message you have to reload the page to see the new post. Which is annoying if it turns into chatting.
Possible solutions: that i've come up with..
extension detects new notification...somehow decide if it's about the page we are at, if yes then in background load the page get the new data and add the stuff to the page already opened. (don't know if it's even possible with the extension)
2nd idea is load after detection and confirmation just reload the page and retain all text that's been written and just scroll to that post again. I inspected the post structure it all looked randomly generated string...couldn't tell if any of the class or id were reliable to identify the textbox.
3rd idea is make new page bottom up that relies on some sort of sdk and updates pages as new post come in..(least favorable to me).
4th idea is forget about retaining the text that has been typed, if all inputs are empty and there is new notification reload the page...( i really wish reloading wasn't involved.
You can use the Javascript SDK and an AJAX post. When the server responds, if nothing extraordinary happened (no access token is expired, your facebook app is allowed), then you can handle whatever you want in the callback.

URL tracking functionality

I want my webpage to have two parts. The top part has a textbox. When the user types a URL into the textbox, the bottom part browses to the content of that URL. When the user clicks a link within the bottom part, the bottom part navigates to the new URL, and the textbox in the top part changes to the new URL. How can I do it?
NOTE: This behavior is the same as in Google Translate (e.g. here), but without any translation.
first problem..
Same origin issue
The only way to achieve what you are asking is exactly the way google translate does what it does - which is to use a server-side powered script as a proxy request:
http://translate.google.com/translate_un?depth=1&hl=en&ie=UTF8&prev=_t&rurl=translate.google.com&sl=auto&tl=en&twu=1&u=http://de.wikipedia.org/wiki/USA&lang=de&usg=ALkJrhgoLkbUGvOPUCHoNZIkVcMQpXhxZg
The above is the URL taken from the iframe that Google translate uses to display the translated page. The main thing to note is that the domain part of the URL is the same as the parent page's URL http://translate.google.com -- if both your frame and your parent window do not share the same domain, then your parent window's JavaScript wont be able to access anything within the iframe. It will be blocked by your browser's in-built security.
Obviously the above wont be a problem if in your project you are only ever going to be navigating your own pages (on the same domain), but considering you are proffering Google Translate as an example I'm assuming not.
What would Google do?
What the above URL does is to ask the server-side to fetch the wikipedia page and return it so that the iframe can display it - but to the iframe this page appears to be hosted on translate.google.com rather than wikipedia. This means that the iframe stays within the same origin as the parent window, and means that JavaScript can be used to edit or modify the page within the iframe.
next problem....
Rewrite the proxied content
Basically what I'm saying is that this can't be achieved with just HTML and client-side JavaScript - you need to have something to help from the server-side i.e. PHP, Python, Ruby, Lisp, Node.. and so on. This script will be responsible for making sure the proxied page appears/renders correctly e.g. you will have to make sure relative links to content/images/css on the original server are not broken (you can use the base tag or physically rewrite relative links). There are also many sites that would see this as an illegal use of their site, as per their site's terms of use and so should be black listed from your service.
final problem..?
Prevent the user from breaking away from your proxy
Once you have your proxy script, you can then use an iframe (please avoid using old framesets), and a bit of JavaScript magic that onload or ondomready of the iframe rewrites all of the links, forms and buttons in the page. This is so that when clicked or submitted, they post to your proxy script rather than the original destination. This rewrite code would also have to send the original destination to your proxy script some how - like u in the Google translate URL. Once you've sorted this, it will mean your iframe will reload with the new destination content, but - all importantly - your iframe will stay on the same domain.
too many problems!
If it were me, personally, I'd rethink your strategy
Overall this is not a simple task, and it isn't 100% fullproof either because there are many things that will cause problems:
Certain sites are designed to break out of frames.
There are ways a user can navigate from a page that can not be easily rewritten i.e. any navigation powered by JavaScript.
Certain pages are designed to break when served up from the wrong host.
Sites that do this kind of 'proxying' of other websites can get into hot water with regards to copyright and usage.
The reason why Google can do it is because they have a lot of time, money and resources... oh and a great deal of what Google translate does is actually handled on the server-side - not in JavaScript.
suggestions
If you are looking for tracking users navigating through your own site:
Use Google Analytics.
Or implement a simple server-side tracking system using cookies.
If you are looking to track users coming to your site and then travelling on to the rest of the world wide web:
Give up, web technologies are designed to prevent things like this.
Or join an online marketing company, they do their best to get around the prevention of things like this.
add a javascript function to your second frame -
<frame id="dataframe" src="frame_a.htm" onload="load()">
let the text box have an id - say "test"
function load()
{
document.getElementById('test').value=document.getElementById('dataframe').src
}

How do you keep content from your previous web page after clicking a link?

I'm sorry if this is a newbie question but I don't really know what to search for either. How do you keep content from a previous page when navigating through a web site? For example, the right side Activity/Chat bar on facebook. It doesn't appear to refresh when going to different profiles; it's not an iframe and doesn't appear to be ajax (I could be wrong).
Thanks,
I believe what you're seeing in Facebook is not actual "page loads", but clever use of AJAX or AHAH.
So ... imagine you've got a web page. It contains links. Each of those links has a "hook" -- a chunk of JavaScript that gets executed when the link gets clicked.
If your browser doesn't support JavaScript, the link works as it normally would on an old-fashioned page, and loads another page.
But if JavaScript is turned on, then instead of navigating to an HREF, the code run by the hook causes a request to be placed to a different URL that spits out just the HTML that should be used to replace a DIV that's already showing somewhere on the page.
There's still a real link in the HTML just in case JS doesn't work, so the HTML you're seeing looks as it should. Try disabling JavaScript in your browser and see how Facebook works.
Live updates like this are all over the place in Web 2.0 applications, from Facebook to Google Docs to Workflowy to Basecamp, etc. The "better" tools provide the underlying HTML links where possible so that users without JavaScript can still get full use of the applications. (This is called Progressive Enhancement or Graceful degradation, depending on your perspective.) Of course, nobody would expect Google Docs to work without JavaScript.
In the case of a chat like Facebook, you must save the entire conversation on the server side (for example in a database). Then, when the user changes the page, you can restore the state of the conversation on the server side (with PHP) or by querying your server like you do for the chat (Javascript + AJAX).
This isn't done in Javascript. It needs to be done using your back-end scripting language.
In PHP, for example, you use Sessions. The variables set by server-side scripts can be maintained on the server and tied together (between multiple requests/hits) using a cookie.
One really helpful trick is to run HTTPFox in Firefox so you can actually monitor what's happening as you browse from one page to the next. You can check out the POST/Cookies/Response tabs and watch for which web methods are being called by the AJAX-like behaviors on the page. In doing this you can generally deduce how data is flowing to and from the pages, even though you don't have access to the server side code per se.
As for the answer to your specific question, there are too many approaches to list (cookies, server side persistence such as session or database writes, a simple form POST, VIEWSTATE in .net, etc..)
You can open your last closed web-page by pressing ctrl+shift+T . Now you can save content as you like. Example: if i closed a web-page related by document sharing and now i am on travel web page. Then i press ctrl+shift+T. Now automatic my last web-page will open. This function works on Mozilla, e explorer, opera and more. Hope this answer is helpful to you.

How Facebook detects that you are away?

How Facebook detects your away state (you know, the half moon in the chat window)? How you can check in Javascript if a person is away from your page, even if it's open in the browser?
Do you think there is any library that already does it?
JQuery idleTimer plugin
They have JavaScript which runs every 30-60 seconds and reports back, plus they know if you're browsing to other pages on the site, which would reset the counter.
Note, if you open up Facebook, and then browse another site and never go back to the Facebook tab, you'll be 'away'
This is probably implemented with a idle timeout as discussed here on SO and on other websites.
I would guess that on each request they set a variable that is last activity time. Then they would query that value using AJAX and after a specific amount of time, you are considered "away".

Categories