Skip to content

Instantly share code, notes, and snippets.

@nitishn
Created January 29, 2015 19:02
Show Gist options
  • Save nitishn/19b1650beab3561babc8 to your computer and use it in GitHub Desktop.
Save nitishn/19b1650beab3561babc8 to your computer and use it in GitHub Desktop.
Sometimes you need to send a dataLayer push on an external/internal URL. This is how you do it properly.
$(document).on('click', '.widget-promotion a', function(event) {
var title = $(this).text().trim();
var url = $(this).attr('href');
dataLayer.push({
'event': 'promotion_click',
'promotion_title': title,
'eventCallback': function() { window.location = url },
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment