Skip to content

Instantly share code, notes, and snippets.

(function($) {
var dataLayer = window.dataLayer || [];
var eventString = 'cusevent';
var eventCategoryString = '張曼娟活動頁';
var areaIndex = 0;
var areaIndexArr = [];
$(window).scroll(function() {
var windowHeight = $(window).height();
function isScrolledIntoView(elem) {
var docViewTop = $(window).scrollTop();
var docViewBottom = docViewTop + $(window).height();
var elemTop = $(elem).offset().top;
var elemBottom = elemTop + $(elem).height();
return (elemTop <= docViewBottom) && (elemBottom >= docViewTop);
}
function scrollRatio(percentage) {
var domHeight = Math.max(
document.body.scrollHeight,
document.body.offsetHeight,
document.documentElement.clientHeight,
document.documentElement.scrollHeight,
document.documentElement.offsetHeight);
return parseInt(window.scrollY / (domHeight - window.innerHeight) * 100 / percentage) * percentage || 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
(function($) {
var dataLayer = window.dataLayer || [];
var eventString = 'cusevent';
var eventCategoryString = '2018淡季早鳥優惠';
var eventInfo = [
['.pc-a-bt td:nth-child(1)', '服務按鈕點擊', '預約租車'],
['.pc-a-bt td:nth-child(2)', '服務按鈕點擊', '加入會員'],
(function($) {
var dataLayer = window.dataLayer || [];
var eventString = 'cusevent';
var eventCategoryString = '會員註冊';
$('#rg_button').click(function(e) {
var eventInfo = [
['填寫資料 - E-mail', $('#email').val()],
['填寫資料 - 輸入密碼', $('#passwd1').val()],
['填寫資料 - 輸入確認密碼', $('#passwd2').val()],
(function($) {
var eventCategoryString = '會員註冊';
$('#email').on('change', function() {
pushDatalayer('填寫資料 - E-mail', $(this).val());
});
$('#passwd1').on('change', function() {
pushDatalayer('填寫資料 - 輸入密碼', '次數');
});
$('#passwd2').on('change', function() {
// 至少有一個字元
.+
// 判斷首頁
\/(index\.html)?$
// 符合 /a_myday/ 或 /a_myday/index.php
^\/a_myday/(index.php)?$
// 符合 / 或 /ecshop/
^\/(ecshop\/?)?$
@fergusKe
fergusKe / cookie.js
Last active November 22, 2018 03:33
var jQuery = jQuery || undefined;
(function($) {
tdFun($);
function tdFun($) {
if ($) {
setEvent();
} else {
// 載入jQ
<script>
var jQuery = jQuery || undefined;
(function($) {
var dataLayer = window.dataLayer || [];
var eventCategoryString = '首頁';
eventFun($);
function eventFun($) {