Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function($) {
- $(document).ready(function() {
- $(window).load(function() {
- // Forms based Selectbox GA detection
- $('#views-exposed-form-tours-block select, #trip-finder select, #webform-client-form-110').change(function() {
- // Determine Select form field value
- var label = '';
- var option = $('option:selected', this).text();
- var labelElem = 'label[for=' + $(this).attr('id') + ']';
- label = $(labelElem).text()
- if (label.length == 0) {
- label = $(this).closest('label').text();
- }
- if (label.length == 0) {
- label=$(this).children('option:first').text();
- }
- // Determine Category & Action
- var category = '';
- var action = 'Filter Option';
- if ($(this).attr('id') == 'trip-finder') {
- category = 'Navigate';
- action = 'Travcoa Journey Navigator';
- } else if ($(this).attr('id') == 'webform-client-form-110') {
- category = 'Contact';
- action = 'Inquiry';
- label = 'Reason for Inquiry';
- } else {
- category = 'Navigate';
- }
- var myData = $.trim(label) + ' - ' + option;
- // Push
- _gaq.push(['_trackEvent', category, action, myData]);
- });// end Select GA
- // Forms based Submit GA detection
- $('#views-exposed-form-tours-block, #trip-finder, #mailchimp-lists-user-subscribe-form-newsletter-signup, #mailchimp-lists-user-subscribe-form-newsletter-signup-footer, #mailchimp-lists-user-subscribe-form-newsletter-signup-full, #webform-client-form-6632, #webform-client-form-904, #webform-client-form-3255, #webform-client-form-6162, #webform-client-form-6600, #webform-client-form-111, #webform-client-form-6354, #webform-client-form-6519, #webform-client-form-5678, #webform-client-form-114').submit(function() {
- switch ($(this).attr('id')) {
- case 'trip-finder':
- category = 'Navigate';
- action = 'Travcoa Journey Navigator';
- myData = 'Submit - Shoe Me Journeys';
- break;
- case 'views-exposed-form-tours-block':
- category = 'Navigate';
- action = 'Travcoa Journey Navigator';
- myData = 'Submit - Clear Filters';
- break;
- case 'mailchimp-lists-user-subscribe-form-newsletter-signup':
- category = 'Register';
- action = 'Email Signup';
- myData = 'Sidebar';
- break;
- case 'mailchimp-lists-user-subscribe-form-newsletter-signup-footer':
- category = 'Register';
- action = 'Email Signup';
- myData = 'Footer';
- break;
- case 'mailchimp-lists-user-subscribe-form-newsletter-signup-full':
- category = 'Register';
- action = 'Email Signup';
- myData = 'Newsletter Signup Link';
- break;
- case 'webform-client-form-6632':
- category = 'Register';
- action = 'Email Signup';
- myData = 'Incredible Kenya Email Signup';
- break;
- case 'webform-client-form-904':
- category = 'Request';
- action = 'Quote Request';
- myData = 'Independent Journey Quote Request';
- break;
- case 'webform-client-form-3255':
- category = 'Request';
- action = 'Quote Request';
- myData = 'journey Application';
- break;
- case 'webform-client-form-6162':
- category = 'Request';
- action = 'Quote Request';
- myData = 'Journey Quote Request';
- break;
- case 'webform-client-form-6600':
- category = 'Request';
- action = 'Quote Request';
- myData = 'Cuba Quote Request';
- break;
- case 'webform-client-form-111':
- category = 'Request';
- action = 'Consumer Brochure';
- myData = '';
- break;
- case 'webform-client-form-6354':
- category = 'Request';
- action = 'Promotion Earn 2 Get $200';
- myData = '';
- break;
- case 'webform-client-form-6519':
- category = 'Request';
- action = 'Submit Campaign Lander';
- myData = '';
- break;
- case 'webform-client-form-5678':
- category = 'Request';
- action = 'Agent Brochure';
- myData = '';
- break;
- case 'webform-client-form-114':
- category = 'Request';
- action = 'Employment Application';
- myData = '';
- break;
- default:
- break;
- }
- // Push
- _gaq.push(['_trackEvent', category, action, myData]);
- }); // end Submit GA
- // href Links based GA detection
- $('#node-118 a, #block-menu-block-1 a, #minipanel-left-destinations a, #minipanel-right-destinations a').click(function() {
- $(this).parents('div').each(function(index, attrib) {
- if (attrib.id.length > 0) {
- myElem = attrib.id;
- return false;
- }
- });
- switch (myElem) {
- case 'node-118':
- category = 'Outgoing Link';
- action = 'Travelers Links';
- myData = $(this).attr('href');
- break;
- case 'block-menu-block-1':
- category = 'Navigate';
- action = 'Main Navigation';
- myData = 'Level 1 - ' + $(this).text();
- break;
- case 'minipanel-left-destinations':
- category = 'Navigate';
- action = 'Main Navigation';
- myData = 'Level 2 - ' + $(this).text();
- break;
- case 'minipanel-right-destinations':
- category = 'Navigate';
- action = 'Main Navigation';
- myData = 'Level 3 - ' + $(this).text();
- break;
- default:
- break;
- }
- // Push
- _gaq.push(['_trackEvent', category, action, myData]);
- }); // end href GA
- // no results based GA detection
- if ($('.tours-no-results').length > 0) {
- var sp = ' | ';
- var category = 'Error';
- var action = 'No Results';
- var journey = $('#edit-field-journey-type-tid option:selected').text();
- var experience = $('#edit-field-special-interest-tid-selective option:selected').text();
- var director = $('#edit-field-tour-director-target-id option:selected').text();
- var month = $('#edit-field-departure-dates-value-value-month option:selected').text();
- var filters = journey + sp +experience + sp +director + sp + month;
- myData = $('#trip-finder-region option:selected').text() + sp + $('#page-title').html() + sp + filters;
- // Push
- _gaq.push(['_trackEvent', category, action, myData]);
- }; // end no results GA
- // View Pages based GA detection
- urlList = ['/request-brochure',
- '/travel-agents',
- '/why-travcoa/about-us/press-releases'
- ];
- if(jQuery.inArray($(location).attr('pathname'), urlList)!==-1 || $(location).attr('pathname').indexOf('/press-releases/')>=0) {
- if ($(location).attr('pathname').indexOf('/press-releases/')>=0) {
- category = 'View';
- action = 'Press Release';
- myData = $('#page-title').html();
- } else {
- category = 'View';
- action = $('#page-title').html();
- myData = '';
- }
- // Push
- _gaq.push(['_trackEvent', category, action, myData]);
- }; // end View GA
- // Sample Email GA detection
- $('.email-sample').click(function() {
- category = 'View';
- action = 'Sample Email';
- myData = '';
- // Push
- _gaq.push(['_trackEvent', category, action, myData]);
- }); // end Sample Email GA
- });
- });
- })(jQuery);
Add Comment
Please, Sign In to add comment