Skip to content

Instantly share code, notes, and snippets.

活動事件: Impression
活動標籤: product: {{商品數量}}
活動事件: ProductClick
活動標籤: {{商品名稱}}
活動事件: Detail
活動標籤: {{商品ID}}
活動事件: AddToCart
<!-- 設定 GA path 包含 hash 資訊 -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-66441042-10"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-125318390-1', {
'page_path': window.location.pathname + window.location.hash
});
</script>
<script>
var jQuery = jQuery || undefined;
(function($) {
var dataLayer = window.dataLayer || [];
var eventCategoryString = '首頁';
eventFun($);
function eventFun($) {
var jQuery = jQuery || undefined;
(function($) {
tdFun($);
function tdFun($) {
if ($) {
setEvent();
} else {
// 載入jQ
@fergusKe
fergusKe / cookie.js
Last active November 22, 2018 03:33
// 至少有一個字元
.+
// 判斷首頁
\/(index\.html)?$
// 符合 /a_myday/ 或 /a_myday/index.php
^\/a_myday/(index.php)?$
// 符合 / 或 /ecshop/
^\/(ecshop\/?)?$
(function($) {
var eventCategoryString = '會員註冊';
$('#email').on('change', function() {
pushDatalayer('填寫資料 - E-mail', $(this).val());
});
$('#passwd1').on('change', function() {
pushDatalayer('填寫資料 - 輸入密碼', '次數');
});
$('#passwd2').on('change', function() {
(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()],
<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 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;
}