Skip to content
This repository has been archived by the owner on Jul 28, 2023. It is now read-only.

Commit

Permalink
Merge pull request #762 from GeotrekCE/add_gpx_kml_ga
Browse files Browse the repository at this point in the history
Add gpx kml Google analytic
  • Loading branch information
LePetitTim authored Jul 10, 2020
2 parents d0dbd19 + 98061fc commit 891ec18
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
23 changes: 22 additions & 1 deletion src/app/layout/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function LayoutController($rootScope, $scope, $state, $location, resultsService,
function SidebarHomeController() {
}

function SidebarDetailController($scope, $rootScope, $modal, $stateParams, $location, globalSettings, resultsService, favoritesService, webglService) {
function SidebarDetailController($scope, $window, $rootScope, $modal, $stateParams, $location, globalSettings, resultsService, favoritesService, webglService, Analytics) {

$scope.webGLisEnable = webglService.isEnabled();

Expand Down Expand Up @@ -202,6 +202,27 @@ function SidebarDetailController($scope, $rootScope, $modal, $stateParams, $loca

$scope.back = $rootScope.back;

$scope.gaDownloadGPX = function(item) {
if (globalSettings.GOOGLE_ANALYTICS_ID) {
Analytics.send('event', 'GPX', 'download', item.properties.slug);
}
$window.open(item.properties.gpx, "_self")
};

$scope.gaDownloadKML = function(item) {
if (globalSettings.GOOGLE_ANALYTICS_ID) {
Analytics.send('event', 'KML', 'download', item.properties.slug);
}
$window.open(item.properties.kml, "_self")
};

$scope.gaDownloadPDF = function(item) {
if (globalSettings.GOOGLE_ANALYTICS_ID) {
Analytics.send('event', 'PDF', 'download', item.properties.slug);
}
$window.open(item.properties.printable, "_blank")
};

getResultDetails(false);

}
Expand Down
6 changes: 3 additions & 3 deletions src/app/layout/templates/sidebar-detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</a>
</li>
<li class="toolbar-action print" ng-if="result.properties.printable">
<a class="toolbar-action-link" href="{{::result.properties.printable}}" target="_blank" tooltip-placement="bottom" tooltip="{{'PRINT' | translate}}">
<a class="toolbar-action-link" href ng-click="gaDownloadPDF(result)" tooltip-placement="bottom" tooltip="{{'PRINT' | translate}}">
<ng-include class="print-icon svg-icon" src="'/images/icons/print.svg'"></ng-include>
<span class="toolbar-action-label">{{'PRINT' | translate}}</span>
</a>
Expand All @@ -23,13 +23,13 @@
</a>
<ul class="dropdown-menu" role="menu">
<li class="toolbar-action kml" ng-if="result.properties.kml">
<a class="toolbar-action-link" href="{{::result.properties.kml}}" target="_self" tooltip-placement="bottom" tooltip="{{'KML' | translate}}">
<a class="toolbar-action-link" href ng-click="gaDownloadKML(result)" tooltip-placement="bottom" tooltip="{{'KML' | translate}}">
<span class="txt-icon">KML</span>
<span class="toolbar-action-label">{{'KML' | translate}}</span>
</a>
</li>
<li class="toolbar-action gpx" ng-if="result.properties.gpx">
<a class="toolbar-action-link" href="{{::result.properties.gpx}}" target="_self" tooltip-placement="bottom" tooltip="{{'GPX' | translate}}">
<a class="toolbar-action-link" href ng-click="gaDownloadGPX(result)" tooltip-placement="bottom" tooltip="{{'GPX' | translate}}">
<span class="txt-icon">GPX</span>
<span class="toolbar-action-label">{{'GPX' | translate}}</span>
</a>
Expand Down

0 comments on commit 891ec18

Please sign in to comment.