Skip to content

Commit 2a56e66

Browse files
authored
Merge pull request #4 from nanoapi-io/feature/google-analytics
add google analytics
2 parents 5620325 + d61cb9e commit 2a56e66

File tree

87 files changed

+33748
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+33748
-1
lines changed

β€Ž.github/workflows/build-and-deploy-app.ymlβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Build Deno SPA
1818
run: |
1919
deno install --allow-scripts --reload
20-
VITE_API_URL=https://api.nanoapi.io deno task build:app
20+
VITE_API_URL=${{ vars.VITE_API_URL }} VITE_GOOGLE_ANALYTICS_ID=${{ vars.VITE_GOOGLE_ANALYTICS_ID }} deno task build:app
2121
2222
- name: Deploy to Firebase
2323
# only deploy on main branch

β€Ždeno.jsonβ€Ž

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
"stripe:forward": "deno task stripe:cli listen --forward-to http://host.docker.internal:4000/billing/webhook",
2020
"stripe:mock": "docker run --rm -it -p 12111-12112:12111-12112 stripe/stripe-mock:latest"
2121
},
22+
"lint": {
23+
"exclude": [
24+
"packages/app/dist/**/*",
25+
"packages/app/public/tarteaucitron/**/*"
26+
]
27+
},
2228
"compilerOptions": {
2329
"strict": true
2430
}

β€Žpackages/app/index.htmlβ€Ž

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,100 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4+
<script src="/tarteaucitron/tarteaucitron.min.js"></script>
5+
<script type="text/javascript">
6+
tarteaucitron.init({
7+
"privacyUrl": "", /* Privacy policy url */
8+
"bodyPosition":
9+
"top", /* top to bring it as first element for accessibility */
10+
11+
"hashtag":
12+
"#tarteaucitron", /* Open the panel with this hashtag */
13+
"cookieName": "tarteaucitron", /* Cookie name */
14+
15+
"orientation": "middle", /* Banner position (top - bottom) */
16+
17+
"groupServices": true, /* Group services by category */
18+
"showDetailsOnClick":
19+
true, /* Click to expand the description */
20+
"serviceDefaultState":
21+
"wait", /* Default state (true - wait - false) */
22+
23+
"showAlertSmall":
24+
false, /* Show the small banner on bottom right */
25+
"cookieslist": false, /* Show the cookie list */
26+
27+
"closePopup": false, /* Show a close X on the banner */
28+
29+
"showIcon": false, /* Show cookie icon to manage cookies */
30+
"iconSrc":
31+
"/logo.png", /* Optionnal: URL or base64 encoded image */
32+
"iconPosition":
33+
"BottomRight", /* Position of the cookie (BottomRight - BottomLeft - TopRight - TopLeft) */
34+
35+
"adblocker":
36+
false, /* Show a Warning if an adblocker is detected */
37+
38+
"DenyAllCta": true, /* Show the deny all button */
39+
"AcceptAllCta": true, /* Show the accept all button */
40+
"highPrivacy":
41+
true, /* HIGHLY RECOMMANDED Disable auto consent */
42+
"alwaysNeedConsent":
43+
false, /* Ask the consent for "Privacy by design" services */
44+
45+
"handleBrowserDNTRequest":
46+
false, /* If Do Not Track == 1, disallow all */
47+
48+
"removeCredit": true, /* Remove credit link */
49+
"moreInfoLink": true, /* Show more info link */
50+
51+
"useExternalCss":
52+
false, /* Expert mode: do not load the tarteaucitron.css file */
53+
"useExternalJs":
54+
false, /* Expert mode: do not load the tarteaucitron js files */
55+
56+
//"cookieDomain": ".my-multisite-domaine.fr", /* Shared cookie for multisite */
57+
58+
"readmoreLink": "", /* Change the default readmore link */
59+
60+
"mandatory": true, /* Show a message about mandatory cookies */
61+
"mandatoryCta":
62+
false, /* Show the disabled accept button when mandatory on */
63+
64+
//"customCloserId": "", /* Optional a11y: Custom element ID used to open the panel */
65+
66+
"googleConsentMode":
67+
true, /* Enable Google Consent Mode v2 for Google ads & GA4 */
68+
"bingConsentMode":
69+
true, /* Enable Bing Consent Mode for Clarity & Bing Ads */
70+
"softConsentMode":
71+
false, /* Soft consent mode (consent is required to load the services) */
72+
73+
"dataLayer":
74+
false, /* Send an event to dataLayer with the services status */
75+
"serverSide":
76+
false, /* Server side only, tags are not loaded client side */
77+
78+
"partnersList":
79+
true, /* Show the number of partners on the popup/middle banner */
80+
});
81+
</script>
82+
<script>
83+
tarteaucitron.user.gtagUa = "%VITE_GOOGLE_ANALYTICS_ID%";
84+
// tarteaucitron.user.gtagCrossdomain = ['example.com', 'example2.com'];
85+
tarteaucitron.user.gtagMore = function () {
86+
/* add here your optionnal gtag() */
87+
};
88+
(tarteaucitron.job = tarteaucitron.job || []).push("gtag");
89+
</script>
90+
491
<meta charset="UTF-8" />
592
<link rel="icon" href="/favicon.ico" />
693
<link rel="stylesheet" href="src/styles/index.css" />
794
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
895
<title>NanoAPI</title>
996
</head>
97+
1098
<body>
1199
<div id="root"></div>
12100
<script type="module" src="/src/main.tsx"></script>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 AmauriC
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
[![](https://data.jsdelivr.com/v1/package/npm/tarteaucitronjs/badge)](https://www.jsdelivr.com/package/npm/tarteaucitronjs)
2+
[![npm](https://img.shields.io/npm/v/tarteaucitronjs.svg)](https://www.npmjs.com/package/tarteaucitronjs)
3+
[![GitHub contributors](https://img.shields.io/github/contributors/AmauriC/tarteaucitron.js.svg)](https://github.com/AmauriC/tarteaucitron.js/graphs/contributors)
4+
[![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/AmauriC)
5+
6+
πŸ‘‹ Hey, I'm Amauri, a french dev that build a GDPR friendly cookie manager.
7+
8+
tarteaucitron was initially a simple script for my personal blog (in 2013), a
9+
few months later, the Github repository is opened and tarteaucitron is now
10+
reliable and recognized.
11+
12+
The european cookie law regulates the management of cookies and you should ask
13+
your visitors their consent before exposing them to third party services.
14+
15+
Clearly this script will:
16+
17+
- Disable all services by default,
18+
- Display a banner on the first page view and a small one on other pages,
19+
- Display a panel to allow or deny each services one by one,
20+
- Store the consent in a cookie for 365 days.
21+
22+
Bonus:
23+
24+
- Load service when user click on Allow (without reload of the page),
25+
- Incorporate a fallback system (display a link instead of social button and a
26+
static banner instead of advertising).
27+
28+
# How to use
29+
30+
```html
31+
<script src="/tarteaucitron/tarteaucitron.js"></script>
32+
33+
<script>
34+
tarteaucitron.init({
35+
"privacyUrl": "", /* Privacy policy url */
36+
"bodyPosition":
37+
"bottom", /* or top to bring it as first element for accessibility */
38+
39+
"hashtag": "#tarteaucitron", /* Open the panel with this hashtag */
40+
"cookieName": "tarteaucitron", /* Cookie name */
41+
42+
"orientation":
43+
"middle", /* Banner position (top - bottom - middle - popup) */
44+
45+
"groupServices": false, /* Group services by category */
46+
"showDetailsOnClick": true, /* Click to expand the description */
47+
"serviceDefaultState": "wait", /* Default state (true - wait - false) */
48+
49+
"showAlertSmall": false, /* Show the small banner on bottom right */
50+
"cookieslist": false, /* Show the cookie list */
51+
52+
"showIcon": true, /* Show cookie icon to manage cookies */
53+
// "iconSrc": "", /* Optional: URL or base64 encoded image */
54+
"iconPosition":
55+
"BottomRight", /* Position of the icon between BottomRight, BottomLeft, TopRight and TopLeft */
56+
57+
"adblocker": false, /* Show a Warning if an adblocker is detected */
58+
59+
"DenyAllCta": true, /* Show the deny all button */
60+
"AcceptAllCta":
61+
true, /* Show the accept all button when highPrivacy on */
62+
"highPrivacy": true, /* HIGHLY RECOMMANDED Disable auto consent */
63+
"alwaysNeedConsent":
64+
false, /* Ask the consent for "Privacy by design" services */
65+
66+
"handleBrowserDNTRequest":
67+
false, /* If Do Not Track == 1, disallow all */
68+
69+
"removeCredit": false, /* Remove credit link */
70+
"moreInfoLink": true, /* Show more info link */
71+
"useExternalCss":
72+
false, /* If false, the tarteaucitron.css file will be loaded */
73+
"useExternalJs":
74+
false, /* If false, the tarteaucitron.services.js file will be loaded */
75+
76+
// "cookieDomain": ".my-multisite-domaine.fr", /* Shared cookie for subdomain website */
77+
78+
"readmoreLink":
79+
"", /* Change the default readmore link pointing to tarteaucitron.io */
80+
81+
"mandatory": true, /* Show a message about mandatory cookies */
82+
"mandatoryCta":
83+
true, /* Show the disabled accept button when mandatory on */
84+
85+
// "customCloserId": "", /* Optional a11y: Custom element ID used to open the panel */
86+
87+
"googleConsentMode":
88+
true, /* Enable Google Consent Mode v2 for Google ads and GA4 */
89+
"bingConsentMode":
90+
true, /* Enable Bing Consent Mode for Clarity and Bing Ads */
91+
"softConsentMode":
92+
false, /* Soft consent mode (consent is required to load the services) */
93+
94+
"dataLayer":
95+
false, /* Send an event to dataLayer with the services status */
96+
"serverSide":
97+
false, /* Server side only, tags are not loaded client side */
98+
99+
"partnersList":
100+
false, /* Details the number of partners on the popup and middle banner */
101+
});
102+
</script>
103+
```
104+
105+
# Add a service
106+
107+
[Installation guide](https://tarteaucitron.io/en/free-installation-open-source/)
108+
109+
# Customization
110+
111+
## Create custom service
112+
113+
```js
114+
tarteaucitron.services.mycustomservice = {
115+
"key": "mycustomservice",
116+
"type": "ads|analytic|api|comment|other|social|support|video",
117+
"name": "MyCustomService",
118+
"needConsent": true,
119+
"cookies": ["cookie", "cookie2"],
120+
"readmoreLink": "/custom_read_more", // If you want to change readmore link
121+
"js": function () {
122+
"use strict";
123+
// When user allow cookie
124+
},
125+
"fallback": function () {
126+
"use strict";
127+
// when use deny cookie
128+
},
129+
};
130+
```
131+
132+
## Events
133+
134+
The following events are available:
135+
136+
- (document) `{SERVICE_KEY}_added` for each enabled service
137+
- (document) `{SERVICE_KEY}_loaded` for each enabled service
138+
- (document) `{SERVICE_KEY}_allowed` for each service when allowed
139+
- (document) `{SERVICE_KEY}_disallowed` for each service when disallowed
140+
141+
- (window) `tac.root_available`: the root element with panel has been created,
142+
services will be loaded
143+
- (window) `tac.open_alert`
144+
- (window) `tac.close_alert`
145+
- (window) `tac.open_panel`
146+
- (window) `tac.close_panel`
147+
148+
## Customize text
149+
150+
To change a translation, use `tarteaucitronCustomText` variable. It will be
151+
merge with the translation shipping with TAC. This variable must be defined
152+
before the initialization. For example:
153+
154+
```js
155+
tarteaucitronCustomText = {
156+
'support': {
157+
'title': 'Support client',
158+
},
159+
'close': 'Enregistrer et fermer',
160+
};
161+
tarteaucitron.init(...);
162+
```
163+
164+
There is a special case for engagement text. By the default, the engagement text
165+
is _{SERVICE_NAME} is disabled._, however you can change it per service. For
166+
example:
167+
168+
```js
169+
tarteaucitronCustomText = {
170+
"engage-twitter": "Follow us on Twitter!",
171+
};
172+
```
173+
174+
# Thanks to the sponsors 😊
175+
176+
| ![Amaury Cleuziou](https://avatars.githubusercontent.com/u/26336203?v=4&s=60) | ![Route4me](https://tarteaucitron.io/images/route4me-min.png) | |
177+
| ----------------------------------------------------------------------------- | ------------------------------------------------------------------ | - |
178+
| [Amaury Cleuziou](https://github.com/MoryCorp) - first sponsor πŸŽ‰ | [Route Optimizer and Route Planner Software](https://route4me.com) | |
179+
| | | |
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
| Version | Supported |
6+
| ------- | ------------------ |
7+
| 1.x | :white_check_mark: |
8+
9+
## Reporting a Vulnerability
10+
11+
Please report any security vulnerabilities to amauri@tarteaucitron.io I'll get
12+
back to you within 24 hours and fix the issue asap.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* min ready */
2+
tarteaucitronNoAdBlocker = true;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tarteaucitronNoAdBlocker = true;

0 commit comments

Comments
Β (0)