With a new request comes new solutions and if one has only the internet and their wits, anything can happen.

This was the case when I was asked – “How can we serve up content we control, the ads, to selected areas on other websites and track it?”

Well if you know me this got the brain going, going in the direction of how can we syndicate our content but not buy into a “Ad System”? And while we are on it, how can we not run into CORS same domain origin browser policy. Well I have news for you, there are a few ways to get this accomplished but I chose using technology I was familiar with. So what is the magic solution to all of this? Well it is a few things.

Environment:

Server under our control – Apache 2.4, OpenSSL, PHP 5.5 on Ubuntu Server v14.xx
Other Servers – We can only provide a JavaScript snippet so as to limit what resources will be needed.

Tools & Resources:

PHP Proxy – Ben Alman, Great work man! This is the CORS magic. (http://benalman.com/projects/php-simple-proxy/)
FileZilla Client – FTP Client of choice to get things where they need to be.
jQuery – Because why not? It’s Jcool!
Optional but cool if serving somthing advance like Cover Flow Collections or Video Galleries
RequireJS – Load control

The Client Side Snippet

jQuery JS – //code.jquery.com/jquery-1.12.0.min.js
A div layer with id=”response” style=”width: 100%;” Loading…

// Get Ready, Get Set
$(document).ready(function(){
$.getJSON( "//yourdomain.com/ba-sp.php?url=basecamp.com/", // Get Data
function(data){ // Find What we want in the response
$( "#response" ).html($(data.contents).find(".bc3-home__hero"));
});
$.ajaxSetup({ cache: false }); // Turn cache off
});

In Action, Check out the console!

Loaded from Basecamp website

Related Posts

Media Things

Push Notifications – Never Miss Out

What is Web-Push Notifications? Web push notifications allow you to send to web visitors even if their browser isn’t open. Chrome supports web push on both desktop and android mobile devices, this can reach users Read more…

Web Solutions

Authentication from the future – Clef

If you have a WordPress site and want it to be safe as can be, look no further. “Account security that your customers will love. Clef’s identity solutions combine cutting-edge design research, and proven security Read more…