How to automatically track when a bit.ly link has been clicked x times - if-statement

I'm looking into running a promotion where users who tweet a custom bit.ly (or any other url link service) link and have that link clicked by others x times (say, 3 times) will automatically have a piece of content (think a pdf) unlocked for them.
I'm at a bit of a loss as to how to accomplish this. I was thinking of using IFTTT.com, but they don't track how many times a bit.ly link has been clicked.
So steps would be the following:
Generate a new unique link to a given webpage
Track when that link has been clicked 3 times
Automatically send user an email when the link has been clicked 3 times with a link to unlocked content
Anyone have any ideas here? All I can think of is scraping bit.ly's stat page periodically and then seeing how often a link has been clicked, but that seems potentially quite slow and resource intensive.

The clicks API endpoint will tell you, but it's pull-based, not push, and there are API rate limits.

You could host your own URL shortener that would take care of counting the clicks, then redirecting to bit.ly/whatever, emailing, etc.
For instance: http://yourls.org/
Edit: well, bit.ly seems to have a pretty nice API. Check http://dev.bitly.com/link_metrics.html#v3_link_clicks

Related

extracting data from facebook using graph api

how can i extract name list && phone numbers of the users liking certain page ?
I have tried using software called facepager but i couldn't extract names .
note:I'm not the owner of the page
You'd most likely have to write code yourself to do something like this. However,
Almost no-one publicly shares their phone number.
Facebook try to prevent this kind of data collection.
Even when facebook list's "likers" of a page, it'll wait till you scroll down to load more. You'd have to play with your browsers debug tools and look into where it get's that data from
https://www.facebook.com/search/<group id here>/likers
In the end you'll probably not get much better than just searching for the page and clicking each person's profile because the site is designed to not let what you're trying to do happen...

Is it possible to select all events in my city where most attendees are within my age range?

Using facebook graph API, is it possible to make a search that would return a list of all events in my city, where most (say >50%) of the attendees are within my age range (say born between 1995-2000?)
No, you can't!
What you could do is, fetch all the events in the city, do a loop and check the data you need. I haven't tried to fetch attendees information but i think it is impossible until the user has approved your app.
But #luschn was wrong here. You actually can search events by city.
With a simple graph api search like this: search?q=cityname&type=event
It will search all the event names with that city name in it.
But keep in mind that not all the events are displayed there. You could also do what #luschn recommended but it will take a lot of time to go through all the pages and their events.
If you're trying to build an app that would show nearest events then it's pointless. Theres one website (https://www.minek.ee/tartu). It's in my mother tongue but you can use the search to search events outside of Estonia. I bet that this website uses the same tactic to fetch the events but they are doing the fetching in background while displaying you all the fetched events one by one.
Still, this app doesn't have much traffic so i think there's no point to build anything like this because people really aren't interested in this. I know that i shouldn't give out opinions but i'm pretty sure that building this is just waste of time. Why?? Because i've already built one and it wasn't worth the time.

Django save before leaving page prompt [duplicate]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
I am currently building a registration page where if the user leaves, I want to pop up a CSS box asking him if he is sure or not. I can accomplish this feat using confirm boxes, but the client says that they are too ugly. I've tried using unload and beforeunload, but both cannot stop the page from being redirected. Using those to events, I return false, so maybe there's a way to cancel other than returning false?
Another solution that I've had was redirecting them to another page that has my popup, but the problem with that is that if they do want to leave the page, and it wasn't a mistake, they lose the page they were originally trying to go to. If I was a user, that would irritate me.
The last solution was real popup window. The only thing I don't like about that is that the main winow will have their destination page while the pop will have my page. In my opinion it looks disjoint. On top of that, I'd be worried about popup blockers.
Just to add to everyones comments. I understand that it is irritating to prevent users from exiting the page, and in my opinion it should not be done. Right now I am using a confirm box at this point. What happens is that it's not actually "preventing" the user from leaving, what the client actually wants to do is make a suggestion if the user is having doubts about registering. If the user is halfway through the registraiton process and leaves for some reason, the client wants to offer the user a free coupon to a seminar (this client is selling seminars) to hopefully persuade the user to register. The client is under the impression that since the user is already on the form, he is thinking of registering, and therefore maybe a seminar of what he is registering for would be the final push to get the user to register. Ideally I don't have to prevent the user from leaving, what would be just as good, and in my opinion better is if I can pause the unload process. Maybe a sleep command? I don't really have to keep the user on the page because either way they will be leaving to go to a different page.
Also, as people have stated, this is a terriable title, so if someone knows a better one, I'd really appreciate it if they could change the title to something no so spammer inviting.
As soon as I saw the words "prevent the user" I started to wail in agony. Never prevent the user, only help them.
If they see your registration page and run off, that's their choice. Pop up a javascript confirm box if they've already filled in some data (because they might be navigating away accidentally) but leave it at that. If they haven't touched the form, leave them alone - they don't want to fill in your form.
Look at other methods of engaging users. If your form is huge and scary, break it into simple manageable chunks or better yet, simplify things so much that the user only gives you data when you need it. For example, you might not need their address until you want to post something to them.
By breaking it into multiple parts you can hook them with a simple form and once they've invested that time, they'll be more likely to continue the process.
But don't harass users. If they don't want to register, pestering them with pop-ups and jaavscript dialogues will just chase them off the site completely.
With that in mind, assuming you're just trying to stop people half-filling-in forms, there are a couple of options to genuinely help people:
Detect if the form has changed and ask them a simple confirm() message.
This is all you can do. A CSS "pop-in" just won't work because you can't control* the window location in the unload event.
*You can put an event listener on all your page's links to fire off something to check the form, but this only helps if the user clicks on one of those links. It won't help if, for example, the user clicks back or closes the window. You could do both CSS and javascript but you end up with a bit of a mess.
Persist the state of the form behind the scenes.
An extension to #1. Instead of squabbling with the user, let them go where they want but save the content of the form either to session or cookie (if it'll fit) and put something on the page (like SO's orange prompt bars at the top of the page) that reminds them that they've started filling in a form and gives them a link back to the form.
When they click that link, you load the data out of the cookie (or session) back into the form and let them carry on. This has the clear benefit of letting them do what they like on your site and keeps the data safe.. ish.
If they don't come back and their cookie/session expire, that's their fault. You can only lead a horse to water. It's not your job to force it to drink.
Don't do it.
But if you want, try this. Record mouse positions and detect a quick upward thrust -- the user is reaching for the BIG X or the top left or top right. Now might be your chance for an unobtrusive box in the screen.
I've seen this implement on the web and it is evil.
If you want to trap links, you could rewrite the links in the page to go to a "you really want to leave?" javascript function, passing the destination URL as an argument.
If you wanna keep users from using their "Back" button, or keep them from putting another URL in the address bar, stop. Stop now. (1) Browsers were made to prevent exactly that kind of obnoxious behavior, and (2) Even if they allowed it, see the last two words of (1). It's freaking rude. Your site is not that special, no matter how cool you think it is.
window.onbeforeunload = function() { return "Message"; };
Use a JavaScript like this to display a leave confirmation message.
Here are just a couple of approaches I could think of but they are not without flaw:
Whatcha Gonna Do technique
Detect the mouse position going towards the edges of the browser as the user might be going to close the tab, window, go back, navigate elsewhere among other things. If so, immediately prompt them that that may be a mistake and they are going to lose out on something very valuable. However, the catch here is that you don't know for sure what their intentions were and you might piss them off with that popup. Also, they might use a bunch of shortcuts such as Ctrl+W etc to do the same.
You've Got Mail technique
If you've managed to get hold of the user's email address before they closed the page, you've hit a jackpot. As soon as the user types anything into the email box and then leaves it, immediately send it to the server using AJAX. Save the state of the page into localStorage or on the server using a cookie or something so it can be recreated later. Every couple of hours send them an email giving them a direct link to the previously saved form, and maybe with special offers this time.
History Repeats Itself technique
Then there's the infamous history manipulation where you keep stacking the current page into the document history so the back button renders effectively worthless.
Don't Put All Your Eggs In One Basket technique
Another technique off the top of my head is to create multiple windows in the background with the registration form and keep them all in sync when any the fields in any one changes. This is a classical technique and really puts the "don't put all your eggs in one basket" saying into real-life usage.
Another advantage of this awesome technique is even if the user closes one of the windows, and later comes across an identical cloned window with all the fields they filled up-to-date populated, they might get confused and think that they never closed the page. And guess what, this time they might just go ahead and fill out the registration form. But you have to be cautious with this as anything more than 2 or 3 clones will make it obvious as to what's going on.
You're Winner technique
Another technique is to tell every user they they are the Xth visitor on the site and use a good rounded number for X such as 1000, 10000, 50000, etc. Tell them that they can claim their prize once they register on the site. Imagine how special each user feels when they land on your site. The prize doesn't have to be anything tangible, it can simply be free coupons that you find on the intertubes.
Where Do You Want To Go Today? technique 1
This is basically a rip-off of your answer. Use document.location.href = 'some url' inside your onbeforeunload callback to navigate to a different page before it is unloaded.
1 Firefox only.
Note: there is no silver bullet solution here unless you write your own browser with your own security policies, but these are all optimizations that you can do to make it utterly impossible for users to leave.
Not all browsers support a modal popup, without which your page would go ahead and navigate anyway.
This is real awful requirement. The sort of requirement that is reasonable in a desktop application but entire unreasonable feature of a web site. Imagine being unable to leave a website.
The answer is either use the horrible confirm box and lump it. Or don't ask the user to enter too much data per page. Use a step by step wizard style data entry, the loss due to accidental navigation is minimised.
You can change the Value of the url using document.location.href = "www.website.com"
I can accomplish this feat using confirm boxes, but the client says that they are too ugly.
If the problem is the ugliness of the standard JS popup boxes, try something like this: http://www.sohtanaka.com/web-design/inline-modal-window-w-css-and-jquery/
Apart from that I second what most people are saying: do this with extreme caution if you don't want to lose users.

Facebook Like Button Count for URLS that Already Have Likes/Shares/Comments

I am trying to implement a like button on a blog. The blog gets a decent amount of traffic and most posts get 10-30 likes, 5-10 shares and any number of comments on Facebook. I am implementing a like button for each post using the iFrame code copied straight from Facebook's Like Button page (http://developers.facebook.com/docs/reference/plugins/like/). When I do test URLS, like "test.com" a count will show up; however, when I use a URL from the site that I know has a combination of shares/likes/comments, no count shows. Additionally, when I run the link through the graph.facebook.com, it shows that there are shares (e.g., http://graph.facebook.com/http://test.com). Now, if I pressed the like button I do get a count of "1" to show up. My questions are thus:
1) Should I expect the count to show up for posts that have shares/likes/comments, but I'm just now implementing the button for it?
2) Is there anything special that needs to be done with the URL sent? URL encoding? Adding/not adding "http://"?
3) Is there a latency to the count? For instance are the counts cached and updated at different times?
Thanks for your help!
1) I don't think they will ever show up if they haven't so far.. (see answer 3)
2) No. An URL with or without http:// will be treated as the same URL. But I recommend using http://
3) If by latency you mean delay, then no. Likes/shares/comments count are updated almost instantly.

Is it possible to tell if a user has viewed a portion of the page?

As the title says on a website is it possible to tell if a user has viewed a portion of the page?
Will moving that portion to a separate iframe work? then if they scroll to the bottom, issue a get request for a small image file..forgot the name of the technique..
Update: It is called Web Bug..A Web bug is an object that is embedded in a web page or e-mail and is usually invisible to the user but allows checking that a user has viewed the page or e-mail. One common use is in e-mail tracking. Alternative names are Web beacon, tracking bug, tracking pixel, pixel tag, 1×1 gif, and clear gif.
If you are talking about to check if the user has actually viewed some part of the page you would need to install a web camera and track his eye-movement.
If you are talking about detecting how far the user has scrolled down the page, you can use Javascript to detect this in the OnScroll event. You can then fire some ajax to the server if you need to record this.
I'm not sure this would be ethical - but technically if you use javascript, you could detect the mouseover event of each paragraph tag in the document, and then AJAX that information back to the server. As the user scrolls down the page, they're likely to mouse over the paragraphs, and then you know at least approximately where they've read to.
Not reliably, no.
Simple example: I middle-click on a link, which opens it in a new background tab. I then decide against it, and close the tab without ever looking at it. Any JavaScript trick is going to report that I viewed everything above the fold.
More complicated example: A newbie user doesn't have the browser window maximised, and a portion of the browser window is off-screen. Any JavaScript trick is going to report as if the entire viewport is being viewed, so even restricting your query to only the cases where scrolling occurs will not help.
Unless you require a user action of some kind, all you will be able to tell is that they downloaded some portion, not that they actually looked at it.
Sure. Put that content inside a div, then in your html, with some javascript, capture the onmouseover event and do your work there. If they've put their mouse over something, it's a pretty safe bet that they've seen it, I'd say...
Hope this helps.