Created
July 22, 2021 14:36
-
-
Save LucasGorgal/31b329554676d474bcf85d3347d5fc8c to your computer and use it in GitHub Desktop.
VPO_202107 CPL Redirect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$cpl = $_GET['cpl']; | |
if($cpl == 1) { | |
$video_id = "ArqNAoReTtI"; | |
$google_ads_conversion = "AW-941768981/F3JqCKun69oCEJWCicED"; | |
} elseif($cpl == 2) { | |
$video_id = "qSy16Sop8AI"; | |
$google_ads_conversion = "AW-941768981/5M_oCOqw69oCEJWCicED"; | |
} elseif($cpl == 3) { | |
$video_id = "sptHVF2s6RQ"; | |
$google_ads_conversion = "AW-941768981/unGrCOiLlNsCEJWCicED"; | |
} elseif($cpl == 4) { | |
$video_id = "4w_J8_MOXLI"; | |
$google_ads_conversion = "AW-941768981/EG_7CPOrj9sCEJWCicED"; | |
} else { | |
die("No GET parameter 'cpl' was given"); | |
} | |
$ipod = stripos($_SERVER['HTTP_USER_AGENT'], "iPod"); | |
$iphone = stripos($_SERVER['HTTP_USER_AGENT'], "iPhone"); | |
$android = stripos($_SERVER['HTTP_USER_AGENT'], "Android"); | |
if($ipod || $iphone) { | |
$url = "vnd.youtube://www.youtube.com/watch?v=$video_id&v=$video_id"; | |
} else if($android) { | |
$url = "intent://www.youtube.com/watch?v=$video_id#Intent;package=com.google.android.youtube;scheme=https;end"; | |
} else { | |
$url = "https://www.youtube.com/watch?v=$video_id"; | |
} | |
$mobile_fallback = "https://www.youtube.com/watch?v=$video_id"; | |
?> | |
<html> | |
<head> | |
<script> | |
!function(f,b,e,v,n,t,s) | |
{if(f.fbq)return;n=f.fbq=function(){n.callMethod? | |
n.callMethod.apply(n,arguments):n.queue.push(arguments)}; | |
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; | |
n.queue=[];t=b.createElement(e);t.async=!0; | |
t.src=v;s=b.getElementsByTagName(e)[0]; | |
s.parentNode.insertBefore(t,s)}(window, document,'script', | |
'https://connect.facebook.net/en_US/fbevents.js'); | |
fbq('init', '123553691512182'); | |
fbq('track', '[VPO_202107] CPL-<?php echo $cpl; ?>'); | |
</script> | |
<noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=123553691512182&ev=PageView&noscript=1"/></noscript> | |
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-941768981"></script> | |
<script> | |
window.dataLayer = window.dataLayer || []; | |
function gtag(){dataLayer.push(arguments);} | |
gtag('js', new Date()); | |
gtag('config', 'AW-941768981'); | |
gtag('event', 'conversion', {'send_to': '<?php echo $google_ads_conversion; ?>'}); | |
</script> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
window.setTimeout(function() { | |
window.location.href = "<?php echo $url; ?>"; | |
}, 2000); | |
window.setTimeout(function() { | |
window.location.href = "<?php echo $mobile_fallback; ?>"; | |
}, 2500); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment