Mian Rizwan Mian Rizwan - 3 years ago 99
PHP Question

Displaying Google AdSense Advertisements only Twitter Visitors

Hi I want to Display my Google Adsense ads only when visitors come from Twitter. Currently im using this code this is working for facebook and others but its not working on twitter

if (strpos($ref, 'twitter.com') != false) {?>
<script type="text/javascript"><!--
google_ad_client = "xx-xx-xxxxxxxxxxxxxxxxxx";
/* xxxxxxxx xxxxxx xxx xxx xxx xx xxxxxx */
google_ad_slot = "xxxxxxxxxxxxxx";
google_ad_width = xxx;
google_ad_height = xxx;
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js">

<?php }else{
echo ""; }

Answer Source

Twitter redirects links via https://t.co
look for a t.co referer

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download