Skip to content

Instantly share code, notes, and snippets.

@simondahla
simondahla / eid-widget-fix.js
Last active December 18, 2015 09:49
discount code parser for eventbee widget
// Get discount code in Eventbee widget
var eventID = ''; //Set your event ID here
//Function to get the code from the browser url
function getParameterByName(name)
{
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(window.location.search);
@simondahla
simondahla / vwo-jquery-noduplicate.js
Last active December 19, 2015 07:19
Workaround for VWO Duplicate content due to jQuery loop
if (!vwo_$('#newUniqeIdentifier').length) {
// Do your vwo_$ stuff here
// vwo_$('<h1>Foo</h1>').replaceWith( '<h1 id="newUniqeIdentifier">Bar</h1>' );
}
setTimeout(function(){
// tweet button
var tweeter = $('<a href="https://twitter.com/share" class="twitter-share-button">Tweet</a>');
// facebook 'like' button
var fbLike = $('<iframe class="fbLike" src="http://www.facebook.com/plugins/like.php?href=bestofconversion.com&amp;send=false&amp;layout=standard&amp;width=450&amp;show_faces=false&amp;font=arial&amp;action=like&amp;height=35&amp;colorscheme=light&amp;layout=button_count&amp;appId=2398652648"></iframe>');
$('.social').append(fbLike, tweeter);
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="http://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
window.getComputedStyle(fbLike[0]).getPropertyValue('top');
$(document).ready(function() {
/*####
Load in script only when a DOM element exists.
Use callback function to run
####*/
Modernizr.addTest('foo', $('.bar').length > 0);
Modernizr.load({
@simondahla
simondahla / jquery.iframetracker.js
Created July 30, 2013 11:32
Add Conversion Tracking to an iframe with VWO and iframetracker.js
/**
* jQuery iframe click tracking plugin demo
* Version 1.0 (2013-03-30)
* Copyright © 2013 Vincent Paré
* https://github.com/finalclap/iframeTracker-jquery
*/
(function($){
// Registering new tracking handler
$.fn.iframeTracker = function(handler){
// Storing the new handler into handler list
@simondahla
simondahla / jquery.link-tracking-ga.js
Last active September 27, 2019 17:03
Google Analytics Link Tracking For both GA Classic & GA UA
@simondahla
simondahla / ga-ua-search-tracking-0-results.js
Last active May 2, 2019 18:50
For Universal Google Analytics - Tracking Search Results with 0 hits. Put this in the 0 results page template.
//Define your search query parameter as varible sn
var sn = "q";
var sr = new RegExp(sn+"=[^\&#038;]+");
p = document.location.pathname;
s = document.location.search;
if (!!s.match(sr)) {
sm = s.match(sr).toString();
srs = sm.split("=");
// The next line is where we add the category and add
@simondahla
simondahla / app.js
Created September 20, 2013 21:26 — forked from JacerOmri/app.js
var restify = require('restify'),
mongoose = require('mongoose');
var server = restify.createServer({
name: 'mongo-api'
})
server.listen(7000, function () {
console.log('%s listening at %s', server.name, server.url)
})
db = mongoose.connect("mongodb://localhost/example-api");
@simondahla
simondahla / CCG-VWO.md
Last active December 24, 2015 07:09
How to add a Custom Conversion Goal (CCG) in Visual Website Optimizer (VWO) for a specific test

#Custom Conversion Goal in Visual Website Optimizer (VWO)

How to add a Custom Conversion Goal (CCG) in VWO. Use this to be able to add a CCG for a specific test.

Replace goalId and testlId with your test specific values.

var startTime;function loadJs(url, callback) {  var js = document.createElement('script');  js.async = true;  js.src = url;  var s = document.getElementsByTagName('script')[0];  js.onload = trackTimingCallback;  startTime = new Date().getTime();  s.parentNode.insertBefore(js, s);}function trackTimingCallback(event) {  var endTime = new Date().getTime();  var timeSpent = endTime - startTime;  ga('send', 'timing', 'jQuery', 'Load Library', timeSpent, 'Google CDN');  // Library has loaded. Now you can use it.};