(function () { window.dataLayer = window.dataLayer || []; let homePreheatBanner = { pageName: window.gaInfo && window.gaInfo.pageName, pageCategory: window.gaInfo && window.gaInfo.pageCategory, components: document.querySelectorAll('.ias-car-body'), // 初始化 init: function () { if (this.components.length) { this.components.forEach((component) => { this.initGAHandler(component); }); } }, initGAHandler: function (component) { component.addEventListener('click', (e) => { // 二级导航 class="ga-second-nav" const secondnav = e.target.closest('.ga-second-nav'); // kv部分 class="ga-kv" const jakv = e.target.closest('.ga-kv'); // tab class="ga-tab" const tab = e.target.closest('.ga-tab'); // 视频 class="ga-videoshare" const videoplay = e.target.closest('.ga-video'); // 视频分享 class="ga-video" const videoshare = e.target.closest('.ga-videoshare'); // 视频左右切换 class="ga-video-switch" 父级 ga-video-parent const videoplaySwitch = e.target.closest('.ga-video-switch'); // 图片左右切换 class="ga-pic-switch" 父级 ga-pic-parent 子级 ga-pic const picplaySwitch = e.target.closest('.ga-pic-switch'); // 合作车型图片 class="ga-car-partner" const carpartner = e.target.closest('.ga-car-partner'); // 合作车型筛选 class="ga-car-partner-filter" 父级 ga-car-partner-parent const carpartnerfilter = e.target.closest('.ga-car-partner-filter'); // 了解更多 class="ga-more" const morebtn = e.target.closest('.ga-more'); // 专题页面 class="ga-campaign" const campaignbtn = e.target.closest('.ga-campaign'); // 回到顶部 class="ga-backtop" const backtopbtn = e.target.closest('.ga-backtop'); // 图片查看 class="ga-picswitch" const picSwitch = e.target.closest('.ga-picswitch'); // 图片查看 if (picSwitch) { let pichash = picSwitch.dataset.pichash; let picactiontype = picSwitch.dataset.picactiontype; let picmodule = picSwitch.dataset.picmodule; let picbuttonname = picSwitch.dataset.picbuttonname; let pictile = picSwitch.dataset.pictile; let picurl = picSwitch.dataset.picurl; window.dataLayer.push({ event: 'pic_switch', page_category: this.pageCategory, page_name: this.pageName, page_hash: pichash, action_type: picactiontype, module: picmodule, button_name: picbuttonname, pic_title: pictile, pic_url: picurl, }); // console.log({ // event: 'pic_switch', // page_category: this.pageCategory, // page_name: this.pageName, // page_hash: pichash, // action_type: picactiontype, // module: picmodule, // button_name: picbuttonname, // pic_title: pictile, // pic_url: picurl, // }); } // 二级导航 if (secondnav) { let navhash = secondnav.dataset.navhash; let navactiontype = secondnav.dataset.navactiontype; let navmodule = secondnav.dataset.navmodule; let navmenutype = secondnav.dataset.navmenutype; let navmenuname = secondnav.dataset.navmenuname; let navurl = secondnav.dataset.navurl; window.dataLayer.push({ event: 'second_nav_click', page_category: this.pageCategory, page_name: this.pageName, page_hash: navhash, action_type: navactiontype, module: navmodule, menu_type: navmenutype, menu_name: navmenuname, click_url: navurl, }); // console.log({ // event: 'second_nav_click', // page_category: this.pageCategory, // page_name: this.pageName, // page_hash: navhash, // action_type: navactiontype, // module: navmodule, // menu_type: navmenutype, // menu_name: navmenuname, // click_url: navurl, // }); } // kv部分 if (jakv) { let kvhash = jakv.dataset.kvhash; let kvactiontype = jakv.dataset.kvactiontype; let kvmodule = jakv.dataset.kvmodule; let kvname = jakv.dataset.kvname; let kvbuttonname = jakv.dataset.kvbuttonname; let kvurl = jakv.dataset.kvurl; let kvclicktype = jakv.dataset.kvclicktype; window.dataLayer.push({ event: 'hero_banner_click', page_category: this.pageCategory, page_name: this.pageName, page_hash: kvhash, action_type: kvactiontype, module: kvmodule, banner_name: kvname, button_name: kvbuttonname, click_url: kvurl, click_type: kvclicktype, }); // console.log({ // event: 'hero_banner_click', // page_category: this.pageCategory, // page_name: this.pageName, // page_hash: kvhash, // action_type: kvactiontype, // module: kvmodule, // banner_name: kvname, // button_name: kvbuttonname, // click_url: kvurl, // click_type: kvclicktype, // }); } // tab if (tab) { let tabhash = tab.dataset.tabhash; let tabactiontype = tab.dataset.tabactiontype; let tabmodule = tab.dataset.tabmodule; let tabname = tab.dataset.tabname; window.dataLayer.push({ event: 'tab_click', page_category: this.pageCategory, page_name: this.pageName, page_hash: tabhash, action_type: tabactiontype, module: tabmodule, tab_name: tabname, }); // console.log({ // event: 'tab_click', // page_category: this.pageCategory, // page_name: this.pageName, // page_hash: tabhash, // action_type: tabactiontype, // module: tabmodule, // tab_name: tabname, // }); } // 视频 // if (videoplay) { // let videohash = videoplay.dataset.videohash; // let videoactiontype = videoplay.dataset.videoactiontype; // let videomodule = videoplay.dataset.videomodule; // let videostatus = videoplay.dataset.videostatus; // let videopercentage = videoplay.dataset.videopercentage; // let videotitle = videoplay.dataset.videotitle; // let videourl = videoplay.dataset.videourl; // window.dataLayer.push({ // event: 'video_play', // page_category: this.pageCategory, // page_name: this.pageName, // page_hash: videohash, // action_type: videoactiontype, // module: videomodule, // video_status: videostatus, // video_percentage: videopercentage, // video_title: videotitle, // video_url: videourl, // }); // console.log({ // event: 'video_play', // page_category: this.pageCategory, // page_name: this.pageName, // page_hash: videohash, // action_type: videoactiontype, // module: videomodule, // video_status: videostatus, // video_percentage: videopercentage, // video_title: videotitle, // video_url: videourl, // }); // } // 视频分享 250930 if (videoshare) { let videosharehash = videoshare.dataset.videosharehash; let videoshareactiontype = videoshare.dataset.videoshareactiontype; let videosharemodule = videoshare.dataset.videosharemodule; let videosharemethod = videoshare.dataset.videosharemethod; let videosharetitle = videoshare.dataset.videosharetitle; let videoshareurl = videoshare.dataset.videoshareurl; window.dataLayer.push({ event: 'video_share', page_category: this.pageCategory, page_name: this.pageName, page_hash: videosharehash, action_type: videoshareactiontype, module: videosharemodule, share_method: videosharemethod, video_title: videosharetitle, video_url: videoshareurl, }); // console.log({ // event: 'video_share', // page_category: this.pageCategory, // page_name: this.pageName, // page_hash: videosharehash, // action_type: videoshareactiontype, // module: videosharemodule, // share_method: videosharemethod, // video_title: videosharetitle, // video_url: videoshareurl, // }); } // 视频左右切换 if (videoplaySwitch) { const parent = videoplaySwitch.closest('.ga-video-parent'); const activeVideo = parent.querySelector('.swiper-slide-active .ga-video1'); if (activeVideo != null) { let videoSwitchhash = videoplaySwitch.dataset.videoswitchhash; let videoSwitchactiontype = videoplaySwitch.dataset.videoswitchactiontype; let videoSwitchmodule = videoplaySwitch.dataset.videoswitchmodule; let videoSwitchbuttonName = videoplaySwitch.dataset.videoswitchbuttonname; let videoSwitchtitle = activeVideo.dataset.videotitle; let videoSwitchurl = activeVideo.dataset.videourl; window.dataLayer.push({ event: 'video_switch', page_category: this.pageCategory, page_name: this.pageName, page_hash: videoSwitchhash, action_type: videoSwitchactiontype, module: videoSwitchmodule, button_name: videoSwitchbuttonName, video_title: videoSwitchtitle, video_url: videoSwitchurl, }); // console.log({ // event: 'video_switch', // page_category: this.pageCategory, // page_name: this.pageName, // page_hash: videoSwitchhash, // action_type: videoSwitchactiontype, // module: videoSwitchmodule, // button_name: videoSwitchbuttonName, // video_title: videoSwitchtitle, // video_url: videoSwitchurl, // }); } } // 图片左右切换 if (picplaySwitch) { const parentPic = picplaySwitch.closest('.ga-pic-parent'); const activePic = parentPic.querySelector('.swiper-slide-active .ga-pic'); if (activePic != null) { let picSwitchhash = picplaySwitch.dataset.picswitchhash; let picSwitchactiontype = picplaySwitch.dataset.picswitchactiontype; let picSwitchmodule = picplaySwitch.dataset.picswitchmodule; let picSwitchbuttonName = picplaySwitch.dataset.picswitchbuttonname; let picSwitchtitle = activePic.dataset.pictitle; let picSwitchurl = activePic.dataset.picurl; window.dataLayer.push({ event: 'pic_switch', page_category: this.pageCategory, page_name: this.pageName, page_hash: picSwitchhash, action_type: picSwitchactiontype, module: picSwitchmodule, button_name: picSwitchbuttonName, pic_title: picSwitchtitle, pic_url: picSwitchurl, }); // console.log({ // event: 'pic_switch', // page_category: this.pageCategory, // page_name: this.pageName, // page_hash: picSwitchhash, // action_type: picSwitchactiontype, // module: picSwitchmodule, // button_name: picSwitchbuttonName, // pic_title: picSwitchtitle, // pic_url: picSwitchurl, // }); } } // 合作车型图片 if (carpartner) { let carhash = carpartner.dataset.carhash; let caractiontype = carpartner.dataset.caractiontype; let carmodule = carpartner.dataset.module; let carbuttonname = carpartner.dataset.buttonname; let carbrand = carpartner.dataset.carbrand; let carmodel = carpartner.dataset.carmodel; let carurl = carpartner.dataset.carurl; window.dataLayer.push({ event: 'car_partner_click', page_category: this.pageCategory, page_name: this.pageName, page_hash: carhash, action_type: caractiontype, module: carmodule, button_name: carbuttonname, car_brand: carbrand, car_model: carmodel, click_url: carurl, }); // console.log({ // event: 'car_partner_click', // page_category: this.pageCategory, // page_name: this.pageName, // page_hash: carhash, // action_type: caractiontype, // module: carmodule, // button_name: carbuttonname, // car_brand: carbrand, // car_model: carmodel, // click_url: carurl, // }); } // 合作车型筛选 if (carpartnerfilter) { const parentCar = carpartnerfilter.closest('.ga-car-partner-parent'); let carBrand = parentCar.querySelectorAll('.brands .filter-option.active'); let valuesBrand = ''; valuesBrand = Array.from(carBrand) .map((el) => el.dataset.value) .join(', '); if ($('.brands-all-btn').hasClass('active')) { valuesBrand = '品牌全选'; } let carSolution = parentCar.querySelectorAll('.fangan .filter-option.active'); const valuesSolution = Array.from(carSolution) .map((el) => el.dataset.value) .join(', '); let carModel = parentCar.querySelectorAll('.model .filter-option.active'); const valuesModel = Array.from(carModel) .map((el) => el.dataset.value) .join(', '); let carPower = parentCar.querySelectorAll('.power .filter-option.active'); const valuesPower = Array.from(carPower) .map((el) => el.dataset.value) .join(', '); const path = window.location.pathname; const query = window.location.search; const hash = window.location.hash; const fullPath = path + query + hash; let carfilterhash = carpartnerfilter.dataset.carfilterhash; let carfilteractiontype = carpartnerfilter.dataset.carfilteractiontype; let carfiltermodule = carpartnerfilter.dataset.filtermodule; let carfilterbuttonname = carpartnerfilter.dataset.filterbuttonname; let carfilterbrand = valuesBrand; let carfiltersolution = valuesSolution; let carfiltermodel = valuesModel; let carfilterpower = valuesPower; let carfilterurl = fullPath; window.dataLayer.push({ event: 'car_partner_filter', page_category: this.pageCategory, page_name: this.pageName, page_hash: carfilterhash, action_type: carfilteractiontype, module: carfiltermodule, button_name: carfilterbuttonname, car_brand: carfilterbrand, car_solution: carfiltersolution, car_model: carfiltermodel, car_power: carfilterpower, click_url: carfilterurl, }); // console.log({ // event: 'car_partner_filter', // page_category: this.pageCategory, // page_name: this.pageName, // page_hash: carfilterhash, // action_type: carfilteractiontype, // module: carfiltermodule, // button_name: carfilterbuttonname, // car_brand: carfilterbrand, // car_solution: carfiltersolution, // car_model: carfiltermodel, // car_power: carfilterpower, // click_url: carfilterurl, // }); } // 了解更多 if (morebtn) { let morehash = morebtn.dataset.morehash; let moreactiontype = morebtn.dataset.moreactiontype; let moremodule = morebtn.dataset.moremodule; let morearticlename = morebtn.dataset.morearticlename; let morearticleurl = morebtn.dataset.morearticleurl; let morearticletype = morebtn.dataset.morearticletype; window.dataLayer.push({ event: 'article_click', page_category: this.pageCategory, page_name: this.pageName, page_hash: morehash, action_type: moreactiontype, module: moremodule, article_name: morearticlename, article_url: morearticleurl, article_type: morearticletype, }); // console.log({ // event: 'article_click', // page_category: this.pageCategory, // page_name: this.pageName, // page_hash: morehash, // action_type: moreactiontype, // module: moremodule, // article_name: morearticlename, // article_url: morearticleurl, // article_type: morearticletype, // }); } // 专题了解更多250930 if (campaignbtn) { let campaignhash = campaignbtn.dataset.campaignhash; let campaignactiontype = campaignbtn.dataset.campaignactiontype; let campaignmodule = campaignbtn.dataset.campaignmodule; let campaignname = campaignbtn.dataset.campaignname; let campaignurl = campaignbtn.dataset.campaignurl; let campaigntype = campaignbtn.dataset.campaigntype; window.dataLayer.push({ event: 'campaign_click', page_category: this.pageCategory, page_name: this.pageName, page_hash: campaignhash, action_type: campaignactiontype, module: campaignmodule, campaign_name: campaignname, campaign_url: campaignurl, campaign_type: campaigntype, }); // console.log({ // event: 'campaign_click', // page_category: this.pageCategory, // page_name: this.pageName, // page_hash: campaignhash, // action_type: campaignactiontype, // module: campaignmodule, // campaign_name: campaignname, // campaign_url: campaignurl, // campaign_type: campaigntype, // }); } // 回到顶部 if (backtopbtn) { let backtophash = backtopbtn.dataset.backtophash; let backtopactiontype = backtopbtn.dataset.backtopactiontype; let backtopmodule = backtopbtn.dataset.backtopmodule; let backtoparticlename = backtopbtn.dataset.backtoparticlename; window.dataLayer.push({ event: 'back_to_top_click', page_category: this.pageCategory, page_name: this.pageName, page_hash: backtophash, action_type: backtopactiontype, module: backtopmodule, button_name: backtoparticlename, }); // console.log({ // event: 'back_to_top_click', // page_category: this.pageCategory, // page_name: this.pageName, // page_hash: backtophash, // action_type: backtopactiontype, // module: backtopmodule, // button_name: backtoparticlename, // }); } }); }, }; homePreheatBanner.init(); })(); // 视频埋码 20251011 // 常见视频组件“ga-video1" //视频中心“ga-video3" $('.ga-video1').each(function (i) { $(this).click(function (e) { e.preventDefault(); pageName = window.gaInfo && window.gaInfo.pageName; pageCategory = window.gaInfo && window.gaInfo.pageCategory; let videohash = $(this).data('videohash'); let videoactiontype = $(this).data('videoactiontype'); let videomodule = $(this).data('videomodule'); let videotitle = $(this).data('videotitle'); let videourl = $(this).data('videourl'); let nativeVideo = $('.video-box').eq(i).find('video')[0]; // 初始化 dataLayer 如果不存在 if (typeof window.dataLayer === 'undefined') { window.dataLayer = []; } // 追踪原生视频事件 let trackedPercentages = [25, 50, 75, 100]; let percentagesTracked = []; let hasStarted = false; nativeVideo.addEventListener('play', function () { if (!hasStarted) { hasStarted = true; window.dataLayer.push({ event: 'video_play', video_status: 'start', video_percentage: 0, video_type: 'native', page_hash: videohash, page_category: pageCategory, page_name: pageName, action_type: videoactiontype, module: videomodule, video_title: videotitle, video_url: videourl, }); // console.log({ // event: 'video_play', // video_status: 'start', // video_percentage: 0, // video_type: 'native', // page_hash: videohash, // page_category: pageCategory, // page_name: pageName, // action_type: videoactiontype, // module: videomodule, // video_title: videotitle, // video_url: videourl, // }); } }); nativeVideo.addEventListener('pause', function () { let percent = Math.round((nativeVideo.currentTime / nativeVideo.duration) * 100); if (percent < 99) { window.dataLayer.push({ event: 'video_play', video_status: 'pause', video_percentage: Math.round((nativeVideo.currentTime / nativeVideo.duration) * 100), video_type: 'native', page_hash: videohash, page_category: pageCategory, page_name: pageName, action_type: videoactiontype, module: videomodule, video_title: videotitle, video_url: videourl, }); // console.log({ // event: 'video_play', // video_status: 'pause', // video_percentage: Math.round((nativeVideo.currentTime / nativeVideo.duration) * 100), // video_type: 'native', // page_hash: videohash, // page_category: pageCategory, // page_name: pageName, // action_type: videoactiontype, // module: videomodule, // video_title: videotitle, // video_url: videourl, // }); } }); nativeVideo.addEventListener('ended', function () { window.dataLayer.push({ event: 'video_play', video_status: 'complete', video_percentage: 100, video_type: 'native', page_hash: videohash, page_category: pageCategory, page_name: pageName, action_type: videoactiontype, module: videomodule, video_title: videotitle, video_url: videourl, }); // console.log({ // event: 'video_play', // video_status: 'complete', // video_percentage: 100, // video_type: 'native', // page_hash: videohash, // page_category: pageCategory, // page_name: pageName, // action_type: videoactiontype, // module: videomodule, // video_title: videotitle, // video_url: videourl, // }); }); nativeVideo.addEventListener('timeupdate', function () { let percent = Math.round((nativeVideo.currentTime / nativeVideo.duration) * 99); if (trackedPercentages.some((p) => percent >= p && !percentagesTracked.includes(p))) { let milestone = trackedPercentages.find( (p) => percent >= p && !percentagesTracked.includes(p) ); if (milestone) { percentagesTracked.push(milestone); window.dataLayer.push({ event: 'video_play', video_status: 'progress', video_percentage: milestone, video_type: 'native', page_hash: videohash, page_category: pageCategory, page_name: pageName, action_type: videoactiontype, module: videomodule, video_title: videotitle, video_url: videourl, }); // console.log({ // event: 'video_play', // video_status: 'progress', // video_percentage: milestone, // video_type: 'native', // page_hash: videohash, // page_category: pageCategory, // page_name: pageName, // action_type: videoactiontype, // module: videomodule, // video_title: videotitle, // video_url: videourl, // }); } } }); }); });