Reputation: 78686
Let's say my site is example.com people can visit by directly type in "example.com" in the browser to open it up.
However I want to check if people visit my site from other sources, like google or other referrals. Then I'd like to add jquery modal for those visitors. Is it doable? Thanks!
Upvotes: 1
Views: 889
Reputation: 9959
Google Analytics also provide this referral information, you just apply an account, add a script right before your body tag.
<script>
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'FILL-IN-YOUR-ACCOUNT']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
Upvotes: 0
Reputation: 92
You don't need JQuery; just JavaScript. The document.referrer property, which will give you the site where the visitor was just before example.com, should do the trick for you.
var referrer = document.referrer;
Upvotes: 4