Skip to content

Commit 3f5850a

Browse files
authored
feat(Analytics): Add Google Tag Manager support (#294)
1 parent e7b5de1 commit 3f5850a

File tree

5 files changed

+10
-0
lines changed

5 files changed

+10
-0
lines changed

src/main/java/org/wise/portal/presentation/web/controllers/user/UserAPIController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ protected HashMap<String, Object> getConfig(HttpServletRequest request) {
163163
config.put("contextPath", contextPath);
164164
config.put("currentTime", System.currentTimeMillis());
165165
config.put("googleAnalyticsId", appProperties.getProperty("google_analytics_id"));
166+
config.put("googleTagManagerId", appProperties.getProperty("google_tag_manager_id"));
166167
config.put("googleClientId", googleClientId);
167168
config.put("isGoogleClassroomEnabled", isGoogleClassroomEnabled());
168169
config.put("logOutURL", contextPath + "/api/logout");

src/main/java/org/wise/portal/spring/impl/WebConfig.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public class WebConfig implements WebMvcConfigurer {
7171
@Value("${google_analytics_id:}")
7272
private String googleAnalyticsId;
7373

74+
@Value("${google_tag_manager_id:}")
75+
private String googleTagManagerId;
76+
7477
@Autowired
7578
private ObjectMapper objectMapper;
7679

src/main/resources/application-dockerdev-sample.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ spring.servlet.multipart.max-request-size=100MB
3535
# recaptcha_public_key - [key or leave empty] public key for recaptcha
3636
# recaptcha_private_key - [key or leave empty] private key for recaptcha
3737
# google_analytics_id - [key or leave empty] key for tracking visitors with google analytics. Go here to get your own key: http://analytics.google.com
38+
# google_tag_manager_id - [key or leave empty] key for tracking visitors with google tag manager. Go here to set up your tag manager account: https://tagmanager.google.com/
3839
# cRater_verification_url - [url or leave empty] cRater verification url
3940
# cRater_scoring_url - [url or leave empty] cRater scoring url
4041
# cRater_client_id - [id or leave empty] cRater client token id
@@ -57,6 +58,7 @@ maxWorkgroupSize=3
5758
isRealTimeEnabled=true
5859
isBatchCreateUserAccountsEnabled=true
5960
google_analytics_id=
61+
google_tag_manager_id=
6062
userAgentParseKey=
6163
recaptcha_public_key=
6264
recaptcha_private_key=

src/main/resources/application_sample.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ spring.servlet.multipart.max-request-size=100MB
3535
# recaptcha_public_key - [key or leave empty] public key for recaptcha
3636
# recaptcha_private_key - [key or leave empty] private key for recaptcha
3737
# google_analytics_id - [key or leave empty] key for tracking visitors with google analytics. Go here to get your own key: http://analytics.google.com
38+
# google_tag_manager_id - [key or leave empty] key for tracking visitors with google tag manager. Go here to set up your tag manager account: https://tagmanager.google.com/
3839
# cRater_verification_url - [url or leave empty] cRater verification url
3940
# cRater_scoring_url - [url or leave empty] cRater scoring url
4041
# cRater_client_id - [id or leave empty] cRater client token id
@@ -57,6 +58,7 @@ maxWorkgroupSize=3
5758
isRealTimeEnabled=true
5859
isBatchCreateUserAccountsEnabled=true
5960
google_analytics_id=
61+
google_tag_manager_id=
6062
userAgentParseKey=
6163
recaptcha_public_key=
6264
recaptcha_private_key=

src/test/java/org/wise/portal/presentation/web/controllers/user/UserAPIControllerTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public void getConfig_WISEContextPath_ReturnConfig() {
7676
expect(request.getContextPath()).andReturn("wise");
7777
replay(request);
7878
expect(appProperties.getProperty("google_analytics_id")).andReturn("UA-XXXXXX-1");
79+
expect(appProperties.getProperty("google_tag_manager_id")).andReturn("GTM-XXXXXXXX");
7980
expect(appProperties.getProperty("recaptcha_public_key")).andReturn("recaptcha-123-abc");
8081
expect(appProperties.getProperty("wise4.hostname")).andReturn("http://localhost:8080/legacy");
8182
expect(appProperties.getProperty("discourse_url")).andReturn("http://localhost:9292");
@@ -87,6 +88,7 @@ public void getConfig_WISEContextPath_ReturnConfig() {
8788
assertEquals("wise/api/logout", config.get("logOutURL"));
8889
assertFalse((boolean) config.get("isGoogleClassroomEnabled"));
8990
assertEquals("UA-XXXXXX-1", config.get("googleAnalyticsId"));
91+
assertEquals("GTM-XXXXXXXX", config.get("googleTagManagerId"));
9092
verify(request);
9193
verify(appProperties);
9294
}

0 commit comments

Comments
 (0)