Skip to content

Commit

Permalink
Merge pull request #5416 from IQSS/4660-custom-analytics-config
Browse files Browse the repository at this point in the history
4660 custom analytics config
  • Loading branch information
kcondon authored Jan 11, 2019
2 parents 94db81d + 8c88ed4 commit 36dea68
Show file tree
Hide file tree
Showing 15 changed files with 73 additions and 125 deletions.
1 change: 1 addition & 0 deletions doc/release-notes/4660-custom-analytics-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update your Google and Piwik analytics configurations: Remove the deprecated `:GoogleAnalyticsCode`, `:PiwikAnalyticsId`, `:PiwikAnalyticsHost`, `:PiwikAnalyticsTrackerFileName` settings, and use `:WebAnalyticsCode`. The new setting works like the custom HTML files for branding, which allows for more control of your analytics, making it easier to customize what you prefer to track. See [Installation Guide > Configuration > Web Analytics Code](http://guides.dataverse.org/en/latest/installation/config.html#web-analytics-code) for details.
6 changes: 5 additions & 1 deletion doc/sphinx-guides/source/admin/monitoring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ HTTP traffic can be monitored from the client side, the server side, or both.
Monitoring HTTP Traffic from the Client Side
++++++++++++++++++++++++++++++++++++++++++++

HTTP traffic for web clients that have cookies enabled (most browsers) can be tracked by Google Analytics and Piwik (renamed to "Matomo") as explained in the :doc:`/installation/config` section of the Installation Guide under ``:GoogleAnalyticsCode`` and ``:PiwikAnalyticsId``, respectively. You could also embed additional client side monitoring solutions by using a custom footer (``:FooterCustomizationFile``), which is described on the same page.
HTTP traffic for web clients that have cookies enabled (most browsers) can be tracked by Google Analytics (https://www.google.com/analytics/) and Matomo (formerly "Piwik"; https://matomo.org/) as explained in the :ref:`Web-Analytics-Code` section of the Installation Guide.

To track analytics beyond pageviews, style classes have been added for end user action buttons, which include:

``btn-compute``, ``btn-contact``, ``btn-download``, ``btn-explore``, ``btn-export``, ``btn-preview``, ``btn-request``, ``btn-share``

Monitoring HTTP Traffic from the Server Side
+++++++++++++++++++++++++++++++++++++++++++++
Expand Down
61 changes: 26 additions & 35 deletions doc/sphinx-guides/source/installation/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,27 @@ Once you have the location of your custom CSS file, run this curl command to add

``curl -X PUT -d '/var/www/dataverse/branding/custom-stylesheet.css' http://localhost:8080/api/admin/settings/:StyleCustomizationFile``

.. _Web-Analytics-Code:

Web Analytics Code
------------------

Your analytics code can be added to your Dataverse installation in a similar fashion to how you brand it, by adding a custom HTML file containing the analytics code snippet and adding the file location to your settings.

Popular analytics providers Google Analytics (https://www.google.com/analytics/) and Matomo (formerly "Piwik"; https://matomo.org/) have been set up with Dataverse. Use the documentation they provide to add the analytics code to your custom HTML file. This allows for more control of your analytics, making it easier to customize what you prefer to track.

Create your own ``analytics-code.html`` file using the analytics code snippet provided by Google or Matomo and place it at ``/var/www/dataverse/branding/analytics-code.html``. Here is an example of what your HTML file should like like:

.. code-block:: none
<script>
// Analytics code here...
</script>
Once you have the location of your analytics file, run this curl command to add it to your settings:

``curl -X PUT -d '/var/www/dataverse/branding/analytics-code.html' http://localhost:8080/api/admin/settings/:WebAnalyticsCode``

Going Live: Launching Your Production Deployment
------------------------------------------------

Expand Down Expand Up @@ -872,6 +893,11 @@ See :ref:`Branding Your Installation` above.

See :ref:`Branding Your Installation` above.

:WebAnalyticsCode
+++++++++++++++++

See :ref:`Web-Analytics-Code` above.

:FooterCopyright
++++++++++++++++

Expand Down Expand Up @@ -1126,13 +1152,6 @@ For example, if you want your installation of Dataverse to not attempt to ingest

Limit the number of files in a zip that Dataverse will accept.

:GoogleAnalyticsCode
++++++++++++++++++++

Set your Google Analytics Tracking ID thusly:

``curl -X PUT -d 'trackingID' http://localhost:8080/api/admin/settings/:GoogleAnalyticsCode``

:SolrHostColonPort
++++++++++++++++++

Expand Down Expand Up @@ -1240,34 +1259,6 @@ Here is an example of setting the default auth provider back to ``builtin``:

Set to false to disallow local accounts to be created. See also the sections on :doc:`shibboleth` and :doc:`oauth2`.

:PiwikAnalyticsId
++++++++++++++++++++

Site identifier created in your Piwik instance. Example:

``curl -X PUT -d 42 http://localhost:8080/api/admin/settings/:PiwikAnalyticsId``

:PiwikAnalyticsHost
++++++++++++++++++++

Host FQDN or URL of your Piwik instance before the ``/piwik.php``. Examples:

``curl -X PUT -d stats.domain.tld http://localhost:8080/api/admin/settings/:PiwikAnalyticsHost``

or

``curl -X PUT -d hostname.domain.tld/stats http://localhost:8080/api/admin/settings/:PiwikAnalyticsHost``

:PiwikAnalyticsTrackerFileName
++++++++++++++++++++++++++++++

Filename for the 'php' and 'js' tracker files used in the Piwik code (piwik.php and piwik.js).
Sometimes these files are renamed in order to prevent ad-blockers (in the browser) to block the Piwik tracking code.
This sets the base name (without dot and extension), if not set it defaults to 'piwik'.

``curl -X PUT -d domainstats http://localhost:8080/api/admin/settings/:PiwikAnalyticsTrackerFileName``


:FileFixityChecksumAlgorithm
++++++++++++++++++++++++++++

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ private String getFilePath(String fileTypeParam){
// Style (css)
return settingsService.getValueForKey(SettingsServiceBean.Key.StyleCustomizationFile, nonNullDefaultIfKeyNotFound);

} else if (fileTypeParam.equals(CustomizationConstants.fileTypeAnalytics)) {

// Analytics - appears in head
return settingsService.getValueForKey(SettingsServiceBean.Key.WebAnalyticsCode, nonNullDefaultIfKeyNotFound);

} else if (fileTypeParam.equals(CustomizationConstants.fileTypeLogo)) {

// Logo for installation - appears in header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class CustomizationConstants {

public static String fileTypeStyle = "style";

public static String fileTypeAnalytics = "analytics";

public static String fileTypeLogo = "logo";


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,6 @@ public enum Key {
* https://wiki.apache.org/solr/HighlightingParameters#hl.fragsize
*/
SearchHighlightFragmentSize,
/**
* Domain name specific code for Google Analytics
*//**
* Domain name specific code for Google Analytics
*/
GoogleAnalyticsCode,

/**
* Revert to MyData *not* using the Solr "permission documents" which
* was the behavior in Dataverse 4.2. Starting to use Solr permission
Expand Down Expand Up @@ -289,6 +282,10 @@ Whether Harvesting (OAI) service is enabled
Location and name of CSS customization file
*/
StyleCustomizationFile,
/*
Location and name of analytics code file
*/
WebAnalyticsCode,
/*
Location and name of installation logo customization file
*/
Expand Down
8 changes: 4 additions & 4 deletions src/main/webapp/dataset.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
and !DatasetPage.dataset.deaccessioned
and DatasetPage.showComputeButton()}">
<!-- Compute Button Group -->
<button type="button" id="computeBatch" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<button type="button" id="computeBatch" class="btn btn-default btn-compute dropdown-toggle" data-toggle="dropdown">
<span class="glyphicon glyphicon-flash"/> #{bundle['dataset.compute.computeBtn']} <span class="caret"></span>
</button>
<ul class="dropdown-menu pull-left text-left" role="menu">
Expand Down Expand Up @@ -287,15 +287,15 @@

<!-- Contact/Share Button Group -->
<div class="btn-group pull-right" id="datasetButtonBar" role="group">
<p:commandLink class="text-button bootstrap-button-tooltip" title="#{bundle['dataset.email.datasetContactBtn']}"
<p:commandLink class="text-button btn-contact bootstrap-button-tooltip" title="#{bundle['dataset.email.datasetContactBtn']}"
update=":contactDialog" oncomplete="PF('contactForm').show()" actionListener="#{sendFeedbackDialog.initUserInput}">
<f:setPropertyActionListener target="#{sendFeedbackDialog.userMessage}" value=""/>
<f:setPropertyActionListener target="#{sendFeedbackDialog.userEmail}" value=""/>
<f:setPropertyActionListener target="#{sendFeedbackDialog.messageSubject}" value=""/>
<f:setPropertyActionListener target="#{sendFeedbackDialog.recipient}" value="#{DatasetPage.dataset}"/>
<span class="glyphicon glyphicon-envelope"/> #{bundle['contact.contact']}
</p:commandLink>
<p:commandLink styleClass="text-button bootstrap-button-tooltip" rendered="#{!DatasetPage.workingVersion.deaccessioned}"
<p:commandLink styleClass="text-button btn-share bootstrap-button-tooltip" rendered="#{!DatasetPage.workingVersion.deaccessioned}"
title="#{bundle['dataset.share.datasetShare']}"
oncomplete="PF('shareDialog').show();sharrre();">
<span class="glyphicon glyphicon-share"/> #{bundle['share']}
Expand Down Expand Up @@ -598,7 +598,7 @@
<span class="glyphicon glyphicon-pencil"/> #{bundle['file.dataFilesTab.metadata.addBtn']}
</p:commandLink>
<div class="btn-group" jsf:rendered="#{DatasetPage.dataset.released and !DatasetPage.dataset.deaccessioned}" >
<button class="btn btn-default dropdown-toggle" type="button" styleClass="btn btn-default" data-toggle="dropdown">
<button class="btn btn-default btn-export dropdown-toggle" type="button" styleClass="btn btn-default" data-toggle="dropdown">
<span class="glyphicon glyphicon-export"/> #{bundle['dataset.exportBtn']} <span class="caret"/></button>
<ul class="dropdown-menu" role="menu">
<ui:repeat var="exporter" value="#{DatasetPage.exporters}">
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/dataverse.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@
<!-- END: Edit/Publish Button Group -->
<!-- Email/Link/Share Button Group -->
<div class="btn-group pull-right" role="group">
<p:commandLink type="button" styleClass="text-button bootstrap-button-tooltip" title="#{bundle['dataverse.contact']}"
<p:commandLink type="button" styleClass="text-button btn-contact bootstrap-button-tooltip" title="#{bundle['dataverse.contact']}"
update=":contactDialog" oncomplete="PF('contactForm').show()" actionListener="#{sendFeedbackDialog.initUserInput}">
<f:setPropertyActionListener target="#{sendFeedbackDialog.userMessage}" value=""/>
<f:setPropertyActionListener target="#{sendFeedbackDialog.userEmail}" value=""/>
Expand All @@ -473,7 +473,7 @@
<f:setPropertyActionListener target="#{sendFeedbackDialog.recipient}" value="#{DataversePage.dataverse}"/>
<span class="glyphicon glyphicon-envelope"/> #{bundle['contact.contact']}
</p:commandLink>
<p:commandLink type="button" styleClass="text-button bootstrap-button-tooltip"
<p:commandLink type="button" styleClass="text-button btn-share bootstrap-button-tooltip"
title="#{bundle['dataverse.share.dataverseShare']}"
oncomplete="PF('shareDialog').show();sharrre();">
<span class="glyphicon glyphicon-share"/> #{bundle['share']}
Expand Down
3 changes: 1 addition & 2 deletions src/main/webapp/dataverse_template.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<h:head>
<o:importFunctions type="edu.harvard.iq.dataverse.util.MarkupChecker" />
<f:facet name="first">
<o:resourceInclude path="/CustomizationFilesServlet?customFileType=analytics" />
<title><h:outputText value="#{pageTitle}"/></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<ui:remove><!-- We might want dc_meta_header or jsonld_header at the file level some day.--></ui:remove>
Expand Down Expand Up @@ -113,8 +114,6 @@

//]]>
</script>
<ui:include src="google-analytics-snippet.xhtml"></ui:include>
<ui:include src="piwik-analytics-snippet.xhtml"></ui:include>
</h:body>
</f:view>
</html>
Loading

0 comments on commit 36dea68

Please sign in to comment.