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
@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: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 / 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 / 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 / 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] . " ";
}
?>
<?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;
};
/************************************
* 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
@underdown
underdown / gist:9100764
Created February 19, 2014 20:25
Cookie Based PPC Call Tracking
<?php
if($_GET["ppc"] == “true”) {
$cookieValue = “PPCVisit”;
setcookie(“PPCCampaignTracking”, $cookieValue, time()+60*60*24*90); //90 days
$cookie = $cookieValue;
} else {
$cookie = $_COOKIE["NoTracking"];
@underdown
underdown / htaccess-caching
Created May 16, 2014 19:01
add caching via htaccess
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
@underdown
underdown / split-test-cookies-php
Last active August 29, 2015 14:01
simple split test w/php
<?php
if ($_COOKIE['test'] == '1')
header("Location: http://new.seartcoversunlmited.com");
if (rand(1, 100) > 75){
setcookie("test", 1, time()-(60*60*24*14));
header("Location: http://new.seatcoversunlimited.com");
}else{