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".
Related
We keep making changes on one of our old site and we need to show an alert for the users who come back / repeating visitors or the users already visited.
Since we made the changes, browsers show the cache site to them and hence it shows broken to them when they visit back after we have made changes.
So, I want to show an alert to ONLY repeating visitors to clear their browsers cache.
I use cookies to store information, I tried to show cookie based alert to the clients, but again that alert was also visible to new visitors too, which is obviously not required as their browser seeing my site for the first time and would not reload the cache site.
Is there any way, I can popup an alert ONLY to my existing or repeating visitors using jquery / javascript / php?
That's a really bad idea. As an user I shouldn't have to care about browser caches or even know what they are. Bothering me with an alert isn't good either.
Consider adding a global "cache busting" parameter to all of your asset URLs, like so:
<link rel="stylesheet" href="style.css?v1">
<script src="script.js?v1"></script>
Then all you have to do is change the version number and all your visitor will see the updated assets without having to do anything special.
We've just upgraded group policies at work because of a big migration project. Nevermind... The thing is, some of our users use this java application, which reads the smart card reader. On new machines it doesn't work in IE, it has to run in firefox. The trouble is, that the first time firefox opens it, it says there's no java. As soon as you reload it, it's fine.
As users are users, they hate the thought of having to reload the page, and it's not very elegant either. As the process of upgrading anything in the company is difficult, and I'm only an entry level desktop support guy, it won't get fixed any time soon.
So I was thinking... is there any way to create a shortcut, that would open the page and then reload it once it finishes loading the first time?
It can be a shortcut to a local html file which then redirects it to the final location...
You can use a vbs:
set WScriptShell = CreateObject("WScript.Shell")
WScriptShell.Run("http://www.facebook.com/")
WScript.Sleep(2000)
WScriptShell.SendKeys "{F5}"
This one opens a page in the browser, waits 2000 ms (probably enough for the page to load) and then sends the "F5" key to the currently active window. This may not be a perfect solution, but you can extend it to match your needs.
Have you tried $( document ).ready() and insert the code in this function? This basically waits your whole page to load and after that executes the code in the function.
I am developing a web application and my requirement is as specified below.
I need to display four websites in a single browser window...(which i implemented using frameset)
I need to refresh the whole page (which certainly will refresh frames inside ) after 1 minute to update the frames content....(which i implemented using the java script)...
however in one of the frames i need to login to the 3rd party website. i am able to login and able to view the content after the login...however when the page refresh happens after 1 minute the page will be redirected back to the login page again and i have to login after each page refresh...
I googled this and found that it might be due to frames which does not set the cookies.for this i have implemented P3P policy also but the problem persists...
please provide the solution if anybody knows about this...
The javascript I used to refresh a page is
function timeRefresh(timeoutPeriod) {
window.setTimeout("location.reload(true);", timeoutPeriod);
}
window.onload = timeRefresh(60*1000);
If the cookies for the 3rd party site are set then your P3P looks fine and you can navigate fine for over a minute without losing session then the problem must be something with the timeRefresh()
As you can't get a customized URL of the 3rd party site in order to issue a specific reload and assuming that you have no control over the third party site, I suggest you do something different. Set up some JavaScript to load an image from the site (the logo or something else that won't change, or alternatively a script or page) every minute from a frame that you have control over. Because the browser is the same, any existing cookies from a login will be referenced and it will extend the login.
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)
I have a <div> that holds a google ad. My website is mostly AJAX and there is no need for a browser refresh. That means my ads will not refresh either, which isn't ideal, a user staring at one ad all day.
So I wanted a way to refresh a particular <div> on a page. I found many solutions but they didn't work. For example, using JQuery's html function:
$("#ads").html("google ad script here");
This managed to refresh the whole page no idea how. I can also make an AJAX request to a HTML page that contains the Google ad but I am guessing it will have the same effect as the above attempt.
I do not want to use iFrames.
Is there any other option open to me? My pea brain can not think of anymore. :)
EDIT:
It is allowed since I will be initiating the refresh only when a user clicks a link.
A prime example is Yahoo Mail - their new AJAX mailbox uses this same method, when a user clicks a link then a new ad is shown.
As both of the other answers state, refreshing your AdSense advertisements automatically isn't allowed. I understand that you only intend to refresh the ad in response to user action, but it still isn't allowed, even though it should be!
Remember, the reason why you want to update the advertisements is so that you can show new ones. Displaying an advertisement is called an "impression." When you use code to refresh the ads, you are automatically generating ad impressions.
AdSense Program Policies state (emphasis mine):
Invalid Clicks and Impressions
Clicks on Google ads must result from genuine user interest. Any method that artificially generates clicks or impressions on your Google ads is strictly prohibited. These prohibited methods include but are not limited to repeated manual clicks or impressions, using robots, automated click and impression generating tools, third-party services that generate clicks or impressions such as paid-to-click, paid-to-surf, autosurf, and click-exchange programs, or any deceptive software.
Refreshing your advertisements is a violation of the letter of the rule against generating impressions. With that said, I think any reasonable person would agree that refreshing advertisements in an AJAX app in response to user behavior (e.g. in response to a click) isn't a violation of the spirit of the rule.
For example, imagine rewriting your entire app to stop using AJAX. That's clearly a worse experience for your users (it's slower, the page flashes on every click, the page can't dynamically update in the background), but, by a technicality, it's not a violation of the AdSense Program Policies.
Clearly Google meant to prohibit automatically replacing the advertisements every five seconds (creating a "slideshow" of advertisements). Google also meant to prohibit making your site look more attractive to advertisers by appearing to have more visits than you actually have. I'm sure they didn't intend to prevent you from designing a high-performance AJAX website... but unfortunately sometimes rules have unintended consequences.
Of course, as you originally pointed out, you CAN still refresh your advertisements if you embed them in an iframe and modify its location. (Here's how to use iframes in an AJAX application to refresh AdSense.)
You rejected iframes in your initial question, perhaps because you knew that using iframes would violate Google's policies... but if you insist on breaking the rules, you might as well break them all the way! ;-)
Ultimately, I think you'll find that generating impressions this way isn't worth the risk: you'll "refresh" the ads only to find that Google is just showing you the exact same ads as before.
The new Google DFP 'tags' allow specifically 'ad refreshing for AJAX'
refresh
pubService.refresh(slots)
Refreshes the specified array of slots on the page with new ads.
Parameters:
array slots - Optional array of slots to refresh. If not supplied, all ad slots are refreshed.
Example:
var slot1 = googletag.defineUnit("/1234567/leaderboard", [728, 90], "div-1").addService(googletag.pubads());
var slot2 = googletag.defineUnit("/1234567/skyscraper", [160, 600], "div-2").addService(googletag.pubads());
// The call to refresh fetches a new ad for each slot
googletag.pubads().refresh([slot1, slot2]);
http://support.google.com/dfp_sb/bin/answer.py?hl=en&answer=2372721&expand=pubservice_details#refresh
I know I'm a year and a half late to the party, but... It's possible that the problem with the ads is that they are using document.write (Ad servers are notorious for this, but I don't know if AdSense uses it or not.)
If that's the case, I have a library that can help: writeCapture.js. Example:
$('#ads').writeCapture().html('<script src="whatever-your-adsense-code-is"> </script>');
That's using jQuery, but there is also a standalone version.
As for whether it's a TOS violation... Gmail changes ads dynamically, so it can't be that bad. As long as the content is changing too, I would think it was OK.
You can refresh the Google Ad Slots with the following code. Put this in the JS function you want to refresh the Ads. It should refresh all of the ads on the page.
if ( undefined !== googletag ) {
googletag.pubads().refresh();
}
Google Ad Manager Help - Reload ads without a page refresh
Just include the ads in the pages you are loading via ajax. There can be nothing wrong with loading the ads from a file via ajax on a per page basis.
if I load Read.inc which has some content and an ad
Click something on the page and it takes you to Make.inc which has content an an ad.
Whats wrong with that? That's organic. One load with the ad as part of the content.
It's the same as clicking a link.
I haven't actually tried this yet, but it certainly seems logical.
It is not allowed (according to AdSense terms) to try and reload ads during the page life-cycle. Also, it is hardly possible (thanks to the platform architecture).
It is not allowed. but I think you can use a iframe for that. I saw good tutorials of that.
I tried do it by ajax by I rollback my changes for the Adsense TOS