Skip to content

Instantly share code, notes, and snippets.

View underdown's full-sized avatar

Ryan Underdown underdown

  • Classy Closets
  • Phoenix, AZ
View GitHub Profile
/************************************
* Store Account, Campaign, and AdGroup Level Quality Score
* Version 1.2
* ChangeLog v1.2
* - Changed status to ENABLED
* ChangeLog v1.1
* - Added APPEND option
* - Added ability to create spreadsheet sheets
* - Updated logic for faster spreadsheet insertion
* Created By: Russ Savage
<?php
$ppc_campaign=$_GET["utm_content"];
switch($ppc_campaign) {
case "carpet_cleaning": $phone="480-555-1212";break;
case "tile_cleaning": $phone="480-555-1212";break;
case "carpet_cleaners": $phone="480-555-1212";break;
default: $phone="480-515-1240";break;
};
@underdown
underdown / str_replace vs explode
Created November 22, 2013 00:00
str_replace vs explode
<?php
$headline = $_GET["headline"];
$headline = str_replace('+', ' ', $headline);
$text_line = explode("+",$headline);
for ($start=0; $start < count($text_line); $start++) {
print $text_line[$start] . " ";
}
?>
@underdown
underdown / linkremovalcopy
Last active December 26, 2015 22:39
This is a simple google apps script to autogenerate a link removal request. assuming you have 3 fields, url of link, requester's name and your domain, you can call this script by typing: =createRemovalMessage(A1, A2, A3) in the cell you want to create your message on
function createRemovalMessage(url, name, domain)
{
if(url)
{
return 'Hello, My name is '+name+' I work for the company '+domain+'. We\'ve noticed there is a link at '+url+' We would greatly appreciate it if you could remove it, our website has been penalized and we are working hard to remove that penalty. We worked with an SEO company that built links for us in an unscrupulous manner. We apologize for any inconvenience this may cause, but removing this link should actually help your site\'s overall quality. If you need any help, please don\'t hesitate to contact me directly. I\'d be more than happy to help. The link is directed to '+domain+' Thanks. '+name';
}
else
{
return;
@underdown
underdown / X-Cart to Geckoboard
Created October 24, 2013 21:18
Push X-Cart sales stats to json format for geckoboard (polling - (number and secondary number)- needs some authentication)
<?php
$username = "username";
$password = "pass";
$hostname = "localhost";
$db = "dbname";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
@underdown
underdown / gist:6815103
Created October 3, 2013 18:57
multivariate testing with php and google analytics
<?php
switch(rand(1,4)) {
case 1: $callb = array("call_button2.png", "Click to Call Button a1", "We're Here To Help"); break;
case 2: $callb = array("call_button3.png", "Click to Call Button a2", "Our scheduling department is happy to assist you");break;
case 3: $callb = array("call_button2.png", "Click to Call Button a3", "Our scheduling department is happy to assist you"); break;
case 4: $callb = array("call_button3.png", "Click to Call Button a4", "We're Here To Help");break;
}
?>
<a href="tel:<?php echo $id['PHONE']?>" onclick="_gaq.push(['_trackEvent', 'Mobile', '<?php echo $callb[1];?>', '<?php echo $callb[2];?>'])"><?php echo $id['PHONE']?></a>
@underdown
underdown / gist:6360387
Created August 27, 2013 23:31
universal analytics - track subdomains my way
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
var full = window.location.host;
var parts = full.split('.');
var sub = parts[0];
ga('create', 'UA-42037845-1', 'kingsupplements.com');
ga('send', 'pageview', {
@underdown
underdown / gist:6296854
Created August 21, 2013 16:38
include distinct analytics tags by referrer
$allowed_host = 'd3cream.com';
$host = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
if(substr($host, 0 - strlen($allowed_host)) == $allowed_host) {
include('analytics-d3.php');
} else {
include('analytics.php');
}
@underdown
underdown / gist:6245230
Created August 15, 2013 21:41
cross domain link tracking - Google Analytics (cribbed from http://moz.com/ugc/google-analytics-cross-domain-tracking-made-easy-14596)
<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
// Add onClick _link to all <a> elements on page where href contains example-A.com
$("a[href*='example-A.com']").click(function() {
_gaq.push(['_link', this.href]);
return false;
});
// Add onSubmit _linkByPost to all <form> elements on page where action contains example-A.com
<script type="text/javascript">
(function(w, d, s) {
function go(){
var js, fjs = d.getElementsByTagName(s)[0], load = function(url, id) {
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.src = url; js.id = id;
fjs.parentNode.insertBefore(js, fjs);
};
load('https://apis.google.com/js/plusone.js', 'gplus1js');
// load('https://server.iad.liveperson.net/hc/46830827/?cmd=mTagRepstate&site=46830827&buttonID=12&divID=lpButDivID-1271372870793&bt=1&c=1', 'livechat');