Skip to content

Instantly share code, notes, and snippets.

View blafrance's full-sized avatar

Brian LaFrance blafrance

View GitHub Profile
@blafrance
blafrance / authoritylabs-interface-php
Created March 17, 2015 16:24
AuthorityLabs Interface API PHP Connection Example
<?php
$url = 'URL_OF_RESOURCE'; //url for resource you are trying to retrieve - see http://docs.authoritylabs.apiary.io/ for a list of URLs
$api_key = 'YOUR_API_KEY_HERE'; //your AuthorityLabs interface API key
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Accept: vnd.authoritylabs+json; version=1", "X-API-KEY: $api_key"));
@blafrance
blafrance / ga-youtube.js
Created November 11, 2012 04:50 — forked from kressaty/ga-youtube.js
Track YouTube Events in Google Analytics
//NOTE: you must also include https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/player_api?enablejsapi=1&version=3&showinfo=0";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
@blafrance
blafrance / ga-form-abandonment.js
Created November 11, 2012 04:50 — forked from kressaty/ga-form-abandonment.js
Track Form Abandonment in Google Analytics
// NOTE: this assumes you have loaded jQuery
$(document).ready(function() {
// REPLACE 'UNIQUE_FORM_ID' BELOW WITH THE ID OF YOUR FORM
$('#UNIQUE_FORM_ID input').blur(function () {
if($(this).val().length > 0) {
_gaq.push(['_trackEvent', 'Form: FORM NAME HERE','input_exit_full', $(this).attr('name')]);
}
else {
_gaq.push(['_trackEvent', 'Form: FORM NAME HERE','input_exit_empty', $(this).attr('name')]);
@blafrance
blafrance / ga-twitter.js
Created November 11, 2012 04:50 — forked from kressaty/ga-twitter.js
Twitter Button Google Analytics
// This assumes that you have included the Tweet button via the standard Twitter JS include
// Thanks to Google for most of this code, see the Social Interaction Analytics guide at
// https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSocial
// To track a Tweet, subscribe to the tweet event (note the additional function required
// to determine the query parameter being sent to Twitter):
function trackTwitter(intent_event) {
if (intent_event) {
var opt_pagePath;
if (intent_event.target && intent_event.target.nodeName == 'IFRAME') {
@blafrance
blafrance / ga-facebook.js
Created November 11, 2012 04:50 — forked from kressaty/ga-facebook.js
Facebook Like Button Google Analytics
// This assumes Facebook buttons are using the Facebook Javascript SDK.
// Thanks to Google for most of this code, see the Social Interaction Analytics guide at
// https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSocial
// Facebook provides a Javascript event framework that allows you to subscribe to events
// happening within the Facebook Javascript SDK and provides data accordingly.
// To track a like, subscribe to the edge.create event and then use the callback to
// execute the Analytics tracking code:
@blafrance
blafrance / ga-form-abandonment.js
Created November 11, 2012 04:49 — forked from kressaty/ga-form-abandonment.js
Track Form Abandonment in Google Analytics
// NOTE: this assumes you have loaded jQuery
$(document).ready(function() {
// REPLACE 'UNIQUE_FORM_ID' BELOW WITH THE ID OF YOUR FORM
$('#UNIQUE_FORM_ID input').blur(function () {
if($(this).val().length > 0) {
_gaq.push(['_trackEvent', 'Form: FORM NAME HERE','input_exit_full', $(this).attr('name')]);
}
else {
_gaq.push(['_trackEvent', 'Form: FORM NAME HERE','input_exit_empty', $(this).attr('name')]);
@blafrance
blafrance / al-insights.json
Created October 12, 2012 17:23
Insights Queue Example
{
"url":"http://gangplankhq.com",
"time_requested":"2012-10-02T17:42:17+00:00",
"results":{
"head_data":{
"canonical":{
"href":"http://gangplankhq.com/",
"used":true
},
"meta_data":{