Skip to content

Commit

Permalink
add ga support
Browse files Browse the repository at this point in the history
  • Loading branch information
mizok committed Apr 16, 2022
1 parent 726e536 commit 984c788
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: webpack-template
date:
author: Mizok
version: 0.7.0
version: 0.8.0
tags:
---

Expand Down
13 changes: 13 additions & 0 deletions src/template/ga.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Global site tag (gtag.js) - Google Analytics -->
<%const id=""%>
<script async src="https://www.googletagmanager.com/gtag/js?id=<%=id%>"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', '<%=id%>');
</script>
28 changes: 28 additions & 0 deletions src/template/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,37 @@
<meta name="google" content="notranslate" />
<meta name="format-detection" content="telephone=no">
<title><%= title%></title>
<% const description = ''%>
<% const url = '' %>
<% const author = ''%>
<% const openGraphImageUrl = ''%>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="chrome" content="notranslate">
<meta name="description" content="<%= description%>" />
<meta name="author" content="<%= author%>">
<meta property="og:title" content="<%= title%>">
<meta property="og:type" content="website">
<meta property="og:url" content="<%= url%>">
<meta property="og:image" content="<%= openGraphImageUrl%>">
<meta property="og:site_name" content="<%= title%>">
<meta property="og:description" content="<%= description%>">

<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="<%= url%>" />
<meta name="twitter:title" content="<%= title%>" />
<meta name="twitter:description" content="<%= description%>" />
<meta name="twitter:image" content="<%= openGraphImageUrl%>" />
<meta name="twitter:url" content="<%= url%>" />
<meta itemprop="name" content="<%= title%>">
<meta itemprop="description" content="<%= description%>">
<meta itemprop="image" content="<%= openGraphImageUrl%>">
<title><%= title%></title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link
href="https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;500;700&family=Noto+Serif+TC:wght@400;500;700;900&display=swap"
rel="stylesheet">
<%- include('./ga.ejs')%>
</head>

0 comments on commit 984c788

Please sign in to comment.