Last active
June 17, 2020 08:58
-
-
Save taichunmin/cf896614f97546e981d83aa1cde080e0 to your computer and use it in GitHub Desktop.
能使用變數的 LINE 訊息推送小工具 (+Googla Analytics 追蹤)
This file contains hidden or 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 gaScreenView (lineId, name) { | |
return `https://www.google-analytics.com/collect?${Qs.stringify({ | |
an: 'My App', | |
cd: name, // 畫面名稱, | |
cid: lineId.replace(/^U(\w{8})(\w{4})(\w{4})(\w{4})(\w{12})$/, '$1-$2-$3-$4-$5'), // client id | |
ds: 'app', // 資料來源,填寫為 app | |
t: 'screenview', | |
tid: 'UA-xxxxxxxxx-1', // GA 追蹤代碼 | |
uid: lineId, // LINE userId | |
ul: 'zh-tw', // locale | |
v: 1, // api version | |
z: +new Date() | |
})}` | |
} %> | |
{ | |
"type": "bubble", | |
"hero": { | |
"aspectMode": "cover", | |
"aspectRatio": "20:13", | |
"size": "full", | |
"type": "image", | |
"url": "https://scdn.line-apps.com/n/channel_devcenter/img/fx/01_1_cafe.png", | |
}, | |
"body": { | |
"layout": "vertical", | |
"spacing": "md", | |
"type": "box", | |
"contents": [ | |
{ | |
"type": "text", | |
"text": "${nick_name}的擲骰結果", | |
"weight": "bold", | |
"size": "xl" | |
}, | |
{ | |
"type": "box", | |
"layout": "horizontal", | |
"contents": [ | |
{ | |
"type": "text", | |
"text": "四面骰", | |
"flex": 0 | |
}, | |
{ | |
"type": "text", | |
"text": "${_.random(1,4)}", | |
"align": "end" | |
} | |
] | |
}, | |
{ | |
"type": "box", | |
"layout": "horizontal", | |
"contents": [ | |
{ | |
"type": "text", | |
"text": "六面骰", | |
"flex": 0 | |
}, | |
{ | |
"type": "text", | |
"text": "${_.random(1,6)}", | |
"align": "end" | |
} | |
] | |
}, | |
{ | |
"type": "box", | |
"layout": "horizontal", | |
"contents": [ | |
{ | |
"type": "text", | |
"text": "八面骰", | |
"flex": 0 | |
}, | |
{ | |
"type": "text", | |
"text": "${_.random(1,8)}", | |
"align": "end" | |
} | |
] | |
}, | |
{ | |
"type": "box", | |
"layout": "horizontal", | |
"contents": [ | |
{ | |
"type": "text", | |
"text": "十面骰", | |
"flex": 0 | |
}, | |
{ | |
"type": "text", | |
"text": "${_.random(1,10)}", | |
"align": "end" | |
} | |
] | |
}, | |
{ | |
"type": "box", | |
"layout": "horizontal", | |
"contents": [ | |
{ | |
"type": "text", | |
"text": "十二面骰", | |
"flex": 0 | |
}, | |
{ | |
"type": "text", | |
"text": "${_.random(1,12)}", | |
"align": "end" | |
} | |
] | |
}, | |
{ | |
"height": "1px", | |
"layout": "vertical", | |
"offsetStart": "0px", | |
"offsetTop": "0px", | |
"position": "absolute", | |
"type": "box", | |
"width": "1px", | |
"contents": [ | |
{ | |
"aspectMode": "cover", | |
"aspectRatio": "1:1", | |
"size": "full", | |
"type": "image", | |
"url": "${gaScreenView(line_id, '瀏覽畫面')}" | |
} | |
] | |
} | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment