Skip to content
This repository was archived by the owner on Apr 10, 2021. It is now read-only.

Commit 60c2c6d

Browse files
committed
support ga
1 parent 918ce98 commit 60c2c6d

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Diff for: docker/config/ui/bootstrap.sh

+10
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,14 @@ then
1616
echo "\$PORT is NOT empty"
1717
else
1818
echo "\$PORT is empty, used default port 80"
19+
fi
20+
21+
ls /usr/share/nginx/html
22+
23+
if [ ! -z "$GOOGLE_ANALITYCS" ]
24+
then
25+
echo "settings google analytic for $GOOGLE_ANALITYCS (no regex)"
26+
GA="<script async src=\"https://www.googletagmanager.com/gtag/js?id=$GOOGLE_ANALITYCS\"></script> <script> window.dataLayer = window.dataLayer \|\| []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', '$GOOGLE_ANALITYCS'); </script>"
27+
sed -i -e "s|</body>|$GA|g" /usr/share/nginx/html/index.html
28+
1929
fi

Diff for: raw-cms-app/src/config/router.js

+10
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,14 @@ _router.beforeEach((to, from, next) => {
267267
});
268268
});
269269

270+
if (typeof ga != 'undefined') {
271+
// ga('set', 'page', _router.currentRoute.path);
272+
// ga('send', 'pageview');
273+
274+
_router.afterEach((to, from) => {
275+
ga('set', 'page', to.path);
276+
ga('send', 'pageview');
277+
});
278+
}
279+
270280
export const router = _router;

0 commit comments

Comments
 (0)