mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
97287: Fix GA page-view requests
This commit is contained in:
@@ -24,7 +24,7 @@ export class Angulartics2DSpace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private eventTrack(event) {
|
private eventTrack(event) {
|
||||||
if (event.action === 'pageView') {
|
if (event.action === 'page_view') {
|
||||||
this.statisticsService.trackViewEvent(event.properties.object);
|
this.statisticsService.trackViewEvent(event.properties.object);
|
||||||
} else if (event.action === 'search') {
|
} else if (event.action === 'search') {
|
||||||
this.statisticsService.trackSearchEvent(
|
this.statisticsService.trackSearchEvent(
|
||||||
|
@@ -20,7 +20,7 @@ export class ViewTrackerComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.angulartics2.eventTrack.next({
|
this.angulartics2.eventTrack.next({
|
||||||
action: 'pageView',
|
action: 'page_view',
|
||||||
properties: {object: this.object},
|
properties: {object: this.object},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,10 @@
|
|||||||
import { DOCUMENT } from '@angular/common';
|
import { DOCUMENT } from '@angular/common';
|
||||||
import { Inject, Injectable } from '@angular/core';
|
import { Inject, Injectable } from '@angular/core';
|
||||||
|
|
||||||
import { Angulartics2GoogleAnalytics, Angulartics2GoogleTagManager } from 'angulartics2';
|
import {
|
||||||
|
Angulartics2GoogleAnalytics,
|
||||||
|
Angulartics2GoogleGlobalSiteTag,
|
||||||
|
} from 'angulartics2';
|
||||||
import { combineLatest } from 'rxjs';
|
import { combineLatest } from 'rxjs';
|
||||||
|
|
||||||
import { ConfigurationDataService } from '../core/data/configuration-data.service';
|
import { ConfigurationDataService } from '../core/data/configuration-data.service';
|
||||||
@@ -19,7 +22,7 @@ export class GoogleAnalyticsService {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private googleAnalytics: Angulartics2GoogleAnalytics,
|
private googleAnalytics: Angulartics2GoogleAnalytics,
|
||||||
private googleTagManager: Angulartics2GoogleTagManager,
|
private googleGlobalSiteTag: Angulartics2GoogleGlobalSiteTag,
|
||||||
private klaroService: KlaroService,
|
private klaroService: KlaroService,
|
||||||
private configService: ConfigurationDataService,
|
private configService: ConfigurationDataService,
|
||||||
@Inject(DOCUMENT) private document: any,
|
@Inject(DOCUMENT) private document: any,
|
||||||
@@ -70,7 +73,7 @@ export class GoogleAnalyticsService {
|
|||||||
this.document.body.appendChild(libScript);
|
this.document.body.appendChild(libScript);
|
||||||
|
|
||||||
// start tracking
|
// start tracking
|
||||||
this.googleTagManager.startTracking();
|
this.googleGlobalSiteTag.startTracking();
|
||||||
} else {
|
} else {
|
||||||
// add trackingId snippet to page
|
// add trackingId snippet to page
|
||||||
const keyScript = this.document.createElement('script');
|
const keyScript = this.document.createElement('script');
|
||||||
|
@@ -6,7 +6,12 @@ import { ServerModule, ServerTransferStateModule } from '@angular/platform-serve
|
|||||||
|
|
||||||
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
import { TranslateLoader, TranslateModule } from '@ngx-translate/core';
|
||||||
|
|
||||||
import { Angulartics2, Angulartics2GoogleAnalytics, Angulartics2GoogleTagManager } from 'angulartics2';
|
import {
|
||||||
|
Angulartics2,
|
||||||
|
Angulartics2GoogleAnalytics,
|
||||||
|
Angulartics2GoogleGlobalSiteTag,
|
||||||
|
Angulartics2GoogleTagManager
|
||||||
|
} from 'angulartics2';
|
||||||
|
|
||||||
import { AppComponent } from '../../app/app.component';
|
import { AppComponent } from '../../app/app.component';
|
||||||
|
|
||||||
@@ -63,7 +68,7 @@ export function createTranslateLoader(transferState: TransferState) {
|
|||||||
useClass: AngularticsProviderMock
|
useClass: AngularticsProviderMock
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
provide: Angulartics2GoogleTagManager,
|
provide: Angulartics2GoogleGlobalSiteTag,
|
||||||
useClass: AngularticsProviderMock
|
useClass: AngularticsProviderMock
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user