Category: Code

0

A simple iOS / Android traffic splitter in PHP

The following basic PHP code will split traffic by device with iOS traffic going to the first out link, Android to the second and leftovers to the third. <?php     $ua = strtolower($_SERVER[‘HTTP_USER_AGENT’]);     if (strpos($ua,’iphone’) !== false || strpos($ua,’ipod’) !== false || strpos($ua,’ipad’) !== false) {         $out = ‘https://iosoutlink.com/’;     } elseif (strpos($ua,’android’) !== false) {         $out = ‘https://androidoutlink.com’;     } else {       ...

0

Splitting traffic to different offers on mobile

If you are buying bulk traffic to a mobile offer the chances are that you can split some of your traffic off to different offers. For example if  you have a pin submit that only accepts android but has a much higher payout then you can separate your android traffic and increase your bottom line. There are a few ways to do this using popular tracking software but I prefer...

0

Resize youtube/vimeo iframe to maximum available height and width

Here is the code to make a flexible youtube.com or vimeo.com video fit both the height and width of the containing div. Like a flexible adsense unit it will take up the maximum available space on the page or be constrained within a containing object such as a div. CSS: .vcontainer { position:relative; padding-bottom:56.25%; padding-top:30px; height:0; overflow:hidden; } .vcontainer iframe, .vcontainer object, .vcontainer embed { position:absolute; top:0; left:0; width:100%; height:100%;...

0

Calculate distance between two geocooridnates

Here is a javascript function to calculate the distance between two latitude and longitude coordinates. function deg2rad(deg) { return deg * (Math.PI/180) } function calcDistance(lat1,lon1,lat2,lon2) {   var R = 6371; // Radius of the earth in km   var dLat = deg2rad(lat2-lat1);   var dLon = deg2rad(lon2-lon1);   var a =     Math.sin(dLat/2) * Math.sin(dLat/2) +     Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *     Math.sin(dLon/2) * Math.sin(dLon/2)     ;   var...

0

Option to Disable Adsense Ads

In some cases it is beneficial to provide a link or option for visitors to a site not to see the adsense ads the first time they visit a page. Ads can sometimes be viewed negatively and for the first visit or under certain circumstances it is best to temporarily disable them. Here is the code so that you can just add ?noads=1 to the end of your url and...

Automatic Redirect for Mobile Landing Page 0

Automatic Redirect for Mobile Landing Page

Want a mobile lander with a 90%+ “CTR”? Simply add the following javasript: <script> function go() { location.href = ‘http://www.jamesbachini.com’; } function init() { setTimeout(function() { confirm(‘You have two friends who recommended this app’); },3000); setTimeout(function() { go(); },5000); } </script> Then run the init function on body load like so: <body onload=”init();”> This does two things it ensures the user has seen the page, all be it briefly, and...

retargeting on google and facebook 0

Setting Up Retargeting Pixels for Adwords and Facebook

Retargeting works by placing a image pixel or code snippet on your website. You can then launch advertising campaigns targeted at those specific users that have visited the page and “seen” the hidden pixel. This is how to set it up… Facebook Go to Ads Manager > Audiences > Create Audience > Custom Audience > Website Traffic Set in the last to a max of 180 days if required Enter...

Setting up Maxmind GEOIP2 Legacy Database with PHP or Javascript 0

Setting up Maxmind GEOIP2 Legacy Database with PHP or Javascript

This is the php code I use to access geoip data from Maxmind’s geoip database: <?php $gpath = getcwd() . “/GeoIPCity.dat”; if (isset($_SERVER[‘HTTP_X_FORWARDED_FOR’])) { $myip = $_SERVER[‘HTTP_X_FORWARDED_FOR’]; } if (isset($_SERVER[‘REMOTE_ADDR’])) { $myip = $_SERVER[‘REMOTE_ADDR’]; } include(“./geoipcity.inc”); $gi = geoip_open($gpath,GEOIP_STANDARD); $record = geoip_record_by_addr($gi,$myip); $city = $record->city; $countrycode = $record->country_code; geoip_close($gi); echo ‘countrycode = “‘.$countrycode.’”; city = “‘.$city.’”;’; ?> It sets city and countrycode vars, the two lines you’ll need to edit...

Dealing With Googles Mobile Friendly Algorithm 0

Dealing With Googles Mobile Friendly Algorithm

From the 21st April Google will be penalising sites for mobile search which don’t appear mobile friendly. You can test your site here: https://www.google.com/webmasters/tools/mobile-friendly/ If you haven’t done any mobile design you’ll probably get some warnings like this: Text too small to read Links too close together Mobile viewport not set Content wider than screen The first thing you should do to make your site mobile friendly is add a...

Google Friendly Mobile Pages Test 0

Google Friendly Mobile Pages Test

Google have provided a tool which checks to see if a site renders clearly in a mobile browser. The tool looks like it is setup at 320px and if your site works at this you’ll get a “mobile-friendly” tag in your organic search listings. Here’s the link to check your sites: https://www.google.com/webmasters/tools/mobile-friendly/ Some other good sites for checking across different screen sizes/browsers are: http://validator.w3.org/mobile/ – Validates markup, I always have...