Last active
December 12, 2019 06:08
-
-
Save fergusKe/f720a348b017ca453dee7a82a49344d3 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
$('.df_content .item a').on('click', function() { | |
var $this = $(this); | |
var type = $('.bd_product_title').text().trim(); | |
var action = type + '類別-商品點擊'; | |
// 範圍寬度 / 產品寬度 => 一列有幾個 col | |
var col = Math.floor($('.df_content').width() / ($('.df_content .item').width() + 10)); | |
// 當前產品是第幾個項目 / 一列有幾個 col => 當前產品是第幾列 | |
var idx = $this.parents('.item').index(); | |
var row = Math.ceil(idx / col); | |
if (idx % col === 0) { | |
row += 1; | |
} | |
var label = '第' + row + '列_' + $this.parents('.item').find('.df_summary').text().trim(); | |
pushDatalayer(action, label); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment