Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add seperate analytics config for universal links
  • Loading branch information
poeti8 committed Jun 16, 2019
1 parent 1cf87f6 commit db8a4e9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .example.env
Expand Up @@ -42,6 +42,10 @@ GOOGLE_SAFE_BROWSING_KEY=
# Example: UA-XXXX-XX
GOOGLE_ANALYTICS=

# Google Analytics tracking ID for universal analytics
# This one is used for links
# GOOGLE_ANALYRICS_UNIVERSAL=

# Your email host details to use to send verification emails.
# More info on http://nodemailer.com/
# Mail from example "Kutt <support@kutt.it>". Leave empty to use MAIL_USER
Expand Down
4 changes: 4 additions & 0 deletions .template.env
Expand Up @@ -38,6 +38,10 @@ GOOGLE_SAFE_BROWSING_KEY={{GOOGLE_SAFE_BROWSING_KEY}}
# Example: UA-XXXX-XX
GOOGLE_ANALYTICS={{GOOGLE_ANALYTICS}}

# Google Analytics tracking ID for universal analytics
# This one is used for links
GOOGLE_ANALYRICS_UNIVERSAL={{GOOGLE_ANALYRICS_UNIVERSAL}}

# Your email host details to use to send verification emails.
# More info on http://nodemailer.com/
# Mail from example "Kutt <support@kutt.it>". Leave empty to use MAIL_USER
Expand Down
3 changes: 2 additions & 1 deletion server/configToEnv.js
Expand Up @@ -27,7 +27,8 @@ if (hasServerConfig && hasClientConfig) {
RECAPTCHA_SITE_KEY: clientConfig.RECAPTCHA_SITE_KEY,
RECAPTCHA_SECRET_KEY: serverConfig.RECAPTCHA_SECRET_KEY,
GOOGLE_SAFE_BROWSING_KEY: serverConfig.GOOGLE_SAFE_BROWSING_KEY,
GOOGLE_ANALYTICS: serverConfig.GOOGLE_ANALYTICS || clientConfig.GOOGLE_ANALYTICS,
GOOGLE_ANALYTICS: clientConfig.GOOGLE_ANALYTICS_ID,
GOOGLE_ANALYTICS_UNIVERSAL: serverConfig.GOOGLE_ANALYTICS,
MAIL_HOST: serverConfig.MAIL_HOST,
MAIL_PORT: serverConfig.MAIL_PORT,
MAIL_SECURE: serverConfig.MAIL_SECURE,
Expand Down
4 changes: 2 additions & 2 deletions server/controllers/urlController.js
Expand Up @@ -188,8 +188,8 @@ exports.goToUrl = async (req, res, next) => {
});
}

if (process.env.GOOGLE_ANALYTICS && !isBot) {
const visitor = ua(process.env.GOOGLE_ANALYTICS);
if (process.env.GOOGLE_ANALYTICS_UNIVERSAL && !isBot) {
const visitor = ua(process.env.GOOGLE_ANALYTICS_UNIVERSAL);
visitor
.pageview({
dp: `/${id}`,
Expand Down

0 comments on commit db8a4e9

Please sign in to comment.