Skip to content

Instantly share code, notes, and snippets.

View jamesspittal's full-sized avatar

James Spittal jamesspittal

View GitHub Profile
@jamesspittal
jamesspittal / fix-wordpress-permissions.sh
Last active November 8, 2016 10:13 — forked from Adirael/fix-wordpress-permissions.sh
Fix WordPress file permissions (assuming WordPress is installed in /var/www/html and apache:apache)
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
WP_OWNER=apache
WP_GROUP=apache
WP_ROOT=/var/www/html
WS_GROUP=apache
(function getABTest() {
var abTestName = '',
abTestVariation = '',
abTest = 'No test',
abTestExperiments = optimizely.allExperiments[Object.keys(optimizely.variationMap)];
if (abTestExperiments) {
abTestVariation = Object.keys(optimizely.variationNamesMap).map(function(el) { return optimizely.variationNamesMap[el]; })[0];
abTestName = abTestExperiments.name;
abTest = abTestName + ': ' + abTestVariation;
@jamesspittal
jamesspittal / optimizely-get-country-region-city.js
Created May 18, 2017 16:44
Get region/state/city from Optimizely
/**
* Optimizely automatically works out the location of the visitor ('Country', 'Region' and 'City')
*
* ... so it can be used as an alternative to databases like GeoIP2 if you already have it on your site
*
* Simple example below.
*/
var visitorProfile = window.optimizely.get('visitor');
var country = visitorProfile.location.country; // "AU"
@jamesspittal
jamesspittal / show-behaviour.js
Created October 13, 2017 04:47
Return our most recent behaviour in Optimizely X (pageviews, events, etc)
var behavior = window.optimizely.get('behavior');
var behaviorQuery = behavior.query({
"version": "0.2",
});
// Optimizely JavaScript API
// http://developers.optimizely.com/javascript/
// To opt a visitor out of Optimizely tracking
// http://www.example.com/page.html?optimizely_opt_out=true
// 1. API Function Calls
// http://developers.optimizely.com/javascript/#api-function-calls-2
@jamesspittal
jamesspittal / optimizely-x-js-api.js
Last active June 4, 2024 10:50
JS API calls for Optimizely X
// Top-level functions
window.optimizely.get('state');
window.optimizely.get('data');
window.optimizely.get('visitor'); // For custom attributes and such
window.optimizely.get('behavior'); // For behavior queries
// Common examples
window.optimizely.get('state').getActiveExperimentIds(); // Returns an array of active experiment IDs on a page.
window.optimizely.get('data').revision; // Returns the revision that the snippet on the page is on. Useful in determining whether you are looking at the most updated changes made within a campaign.
window.optimizely.get('state').getVariationMap(); // Returns an object of experiment IDs and the corresponding variation ID a user has been bucketed into. Equivalent of classic Optimizely Testing's optimizelyBuckets cookie (which is no longer available within Optimizely X Web).
// ==UserScript==
// @name CS VWO Info
// @version 1.1
// @description Show info on running VWO experiments
// @author Conversion Sciences
// @include /^https?:\/\/.*/
// @grant none
// @noframes
// @downloadURL https://d2t92d45b68dnb.cloudfront.net/TM/VWO.js
// ==/UserScript==
@jamesspittal
jamesspittal / ga-cross-domain-tracking.md
Created July 30, 2019 06:42 — forked from holmberd/ga-cross-domain-tracking.md
Google Analytics - Cross Domain Manual Link Tracking

Manually decorate a URL with the linker parameter for Google Tab Manager or Google Analytics

In the case where you manually want to decorate a link with the linker parameter, i.e. the link is not a valid anchor link, or the final tracking page is accessed by user in a non direct way: File Download, Extension Installation, ect...

Google Analytics

/**
 * Returns the Google Analytics tracker linker parameter.