Implementing mobile vs display tags when hardcoding


#1

Hi,

I am not doing header or anything like that. I am a small publisher. Since you do not have responsive tags, I am looking to find the best workaround to make the ads responsive. Do you know of any code that would help me to do this?

Also, do you have a way to implement and traffic tags for mobile and display separately without using DFP? This would also be through hardcoding.

Thank you,
RA


#2

I’m using PHP and I use this:

// presets:
$ismobile = 0;
$isdesk = 1;
// check for mobile:
if(isset($_SERVER['HTTP_USER_AGENT'])){
	$check_for_device = strtolower($_SERVER['HTTP_USER_AGENT']);
	if(preg_match('/phone|iphone|itouch|ipod|symbian|android|htc_|htc-|palmos|blackberry|opera mini|mobi|windows ce|nokia|fennec|hiptop|kindle|mot |mot-|webos\/|samsung|sonyericsson|^sie-|nintendo|mobile/',$check_for_device)){
		$ismobile = 1;
		$isdesk = 0;
	}
}

Then later on this:

if($isdesk==1){
echo “code for desktop banner tag”;
}else{
echo “code for mobile 300x200 tag”;
}

Together this checks to see if the browser is desktop or mobile, then it shows different tags for each.


#3

Dayvi,

Thank you for the pragmatic and thoughtful answer! We are happy to have you contributing to our community.

Randy, let us know if that works for you, if you can.

Jordan