Last active
December 5, 2018 18:10
-
-
Save framingeinstein/951615ede5ecdf3f27ee2f0967261591 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function initialize () { | |
/* | |
Here is the issue... this assumes a carousel will exist on the page. | |
*/ | |
if(!carousel && _satellite.getVar('pageName') !== "dealer/gallery"){ | |
//console.log('Initialization Delayed 250ms...'); | |
setTimeout(initialize, 250); | |
return; | |
} | |
console.log('Initializing...'); | |
var products = []; | |
if(carousel) { | |
carousel.options.afterAction = onAction; | |
carousel.options.afterInit = function(){ | |
console.log('After Init', arguments); | |
}; | |
carousel.options.afterUpdate = function(){ | |
console.log('After Update', arguments); | |
}; | |
products = getVisibleCarouselListings(products); | |
window.trk.products = UTILS.getProductString( products ); | |
console.log('Triggering productImpression', targetC, products); | |
UTILS.trigger($(targetC).get(0), 'productImpression', {products: products}); | |
} | |
//Track initial items displayed! | |
if(listings.length){ | |
if(_satellite.getVar('pageName') === "dealer/gallery" && options.type === 'pageview'){ | |
products.push({dealerId: _satellite.getVar('Dealer ID p9'), listingId:"galleryview", events: ['event162=1'], merchandizing: []}); | |
} | |
if(_satellite.getVar('pageName') === "detail"){ | |
//products.push({dealerId: _satellite.getVar('Dealer ID p9'), listingId:_satellite.getVar('Listing ID p7'), events: ["event21=0", "event105=1", "event114=1", "event162=0"], merchandizing: []}); | |
} | |
products = getVisibleSearchListings( products ); | |
if(products.length){ | |
window.trk.products = UTILS.getProductString( products ); | |
console.log('Triggering SearchAJAXImpressions' + (options.type ? options.type : ""), targetL, products); | |
window.rec.UTILS.trigger($(targetL).get(0), 'SearchAJAXImpressions' + (options.type ? options.type : ""), {}); | |
} | |
} | |
//console.log('Carousel initialized', carousel); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
// This should be placed in individual rules depending on context | |
$(function(){ | |
var itemsDisplayed = $(window).width() > 768 ? 3 : 2; | |
console.log(window.rec.tracker) | |
if(!window.rec.tracker){ | |
console.log('Tracker does not exist... initial page load') | |
} else { | |
console.log('Tracker exists... AJAX Refresh'); | |
} | |
var tracker = window.rec.Tracker($, {carousel: '#featured-demo', listings: '#listingsContainer', itemsDisplayed: itemsDisplayed}); | |
if(!tracker){ | |
console.log('Tracker did not find a carousel to track!'); | |
} else { | |
console.log('Tracking listings and carousel!', tracker); | |
//console.log('Test', tracker.onAction(tracker.carousel.$elem)); | |
$('#listingsContainer').on('ajax_listings_refresh', function () { | |
console.log('AJAX Refresh!!!'); | |
tracker = window.rec.Tracker($, {tracker: tracker, retrack:true, type: 'pageview'}); | |
//console.log('TEST', tracker, tracker.getVisibleSearchListings(tracker.getVisibleCarouselListings([]))); | |
}); | |
window.rec.tracker = tracker; | |
} | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment