What are the laws that define when should someone do only one day of Yom Tov (Shavuot for example) or 2 days?
For example, how long do you have to stay in Israel? Are there other factors?
Read this moving story which I find very relevant to your question.
The story is told by a holocaust survivor who came to deeply regret not heeding to Rav Kook's begging of him to make Aliyah in the 20's.
The story suggests that the Halachic criterion for a Ben Eretz Yisrael is only the wholehearted decision to live in Eretz Yisrael.
As has been pointed out in the comments a story (even by the great Simchah Raz) is not a viable Halachic source. It is however something to start with to seek out the source for this opinion.
My assumption is that even those who hold this opinion would require a person who has made the decision to make Aliyah to actually be in Israel for the chag, but maybe not.
Again, according to Rabbi Yaakov Emden, you keep 1 day if you're in Israel right now, no matter where you come from or where you intend to be. If you follow his opinion, this question is moot. The prevalence of this opinion has had a resurgence in recent years, especially as we all move around so much, no one really is "of" a specific place like they used to be. (Also, 300 years ago, you'd maybe have a small handful of non-Israelis visiting for yomtov. Today it's a giant industry; as Rabbi Shlomo Zalman Auerbach said, the walls of Jerusalem cry every time the non-Israelis make a second-day yomtov minyan here.)
But assuming we follow the somewhat more mainstream approach, that a non-Israeli keeps 2 days; ask a rabbi. But often the criterion is either:
Regularity with regards to yomtov: someone who has a house and job in America, but has gone to Israel for every yomtov for some time now.
Sincerity and commitment with regards to the move to Israel, generally by putting your money where your mouth is. Someone who just moved to Israel a few weeks ago, but has sold his American house, quit his American job, and moved his whole family to Israel and started a new job in Israel, new house, new bank account, new everything; Rabbi Moshe Feinstein allowed such a person to keep 1 day (and when visiting American relatives, attend their 2nd Passover seder only so as not to cause a scene).
The flipside is the sincere yeshiva boy who swears on a Bible (not literally) that he's never leaving Israel -- but keeps calling his parents in Cedarhurst for money, and if they put their foot down, he'd have to go home. Rabbi Moshe Feinstein told a young R' Asher Zelig Rubinstein that he should have kept 2 days in this case.
Just to add to the many opinions already brought down, Hacham Ovadia Yosef, in Hazon Ovadia Hilchot Yom Tov footnote 22 of Hilchot Yom Tov Sheni Shel Galuyot (and likely elsewhere) writes that a single man or woman from Chutz La'aretz who is old enough to get married can keep one day while in Israel.
He combines the shita of the Hacham Tzvi and Shulchan Aruch Harav, which says that everyone keeps one day in Israel, with the logic that if one doesn't have a family, he isn't tied down to a single location. He says that since, hypothetically, if one would find a shidduch in Israel, a source of income, he would be willing to settle there, he is no longer considered 'tied down' to chutz la'aretz. Even if his parents would object, he argues that a child does not need to heed his parents when it comes to a shidduch.
There's a popular story that generally accompanies this pesak din: a young man once came to Hacham Ovadia and told him that he isn't ready to marry, and therefore should keep two days. Hacham Ovadia asked him, "What if you found the perfect girl, who was willing to marry you today? Wouldn't you marry her?" The boy asserted that he would not. He asked him, "What if I offer you my granddaughter? wouldn't you marry her??" Again, the boy asserted that he would not. Hacham Ovadia concluded, "in that case you're completely patur from all mizvot: you're a shoteh gamur!"
Many Sepharadic students who study in Israel after High School (who the footnote is actually addressed to) rely on this pesak din (but of course CYLOR).
To clarify AviD's answer above - R Shlomo Zalman Auerbach says if you are in Israel for the 3 festivals (that's not just pesach and sukkot) you take on the customs of a person from Israel. So as soon you commit you will keep one day. The Chocham Zvi holds that even passing through Israel you would keep one day, but he asks many questions on this opinion, but since he said it, there is room to be lenient in the matter.
If however you cannot make it to Israel because of circumstances out of your control, you have to keep the full 2 days, and do not put tephilin on 2nd day etc, because you do not become a 1 day person through this, just that you are not relevant to keeping 2 days, because you are never out of Israel for the festival.
51% of days of year will decide if you live in Israel or not for being a 1 day person or not.
Look up Hilchos Shlomo for Yomtov....
I've seen so many different variations on this halacha, some that border on the absurd. On one hand, on the second day of Shavuot I once ate by a family who had lived in Jerusalem for 8 years, kept intending to leave, but had never quite managed to do it -- nevertheless, their rav told them to keep 2 days. On the other hand, I've met people who lived in chutz l'aretz for just as long (or longer) and only kept 1 day of Yom Tov.
I'll try to post the psak found in Yalkut Yosef in another answer, but this really is a question where you need to consult your rav, even if you think you know the answer.
Sorry, I can't find the source right now, but I'll try to come back and fix this up later...
But the defining requirement here is 3 regalim in a row - Sukkot-Pesach-Shavuot. (I think there might be a sub-requirement that they start in the right order, e.g. not starting from Shavuot-Sukkot-Pesach, but if/when I find th source I'm sure that will clear up.)
There is also an opinion that it is based on the source of your income - e.g. even if you live in U.S. "temporarily", but e.g. your parents live in Israel and are financing you whil you're in college, or something - then you'd still keep only 1 day (with certain restrictions on the 2nd day, different question).
However, as others have said - consult with your own Rav.