Edit online

You can use Google Analytics to track and report site data for your WebHelp Responsive output.

Using a Publishing Template

To integrate Google Analytics into your WebHelp Responsive output using an Oxygen Publishing Template, follow this procedure:
  1. Create a new Google Analytics account (if you do not already have one) and log on.
  2. Choose the Analytics solution that best fits the needs of your website.
  3. Follow the on-screen instructions to obtain a Tracking Code that contains your Tracking ID. A Tracking Code looks like this:
    <script>
     (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
     (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
     m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
     })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
    
     ga('create', 'UA-XXXXXXXX-X', 'auto');
     ga('send', 'pageview');
    </script>
  4. Save the Tracking Code (obtained in the previous step) in a new XML file called googleAnalytics.xml. Note that the file should only contain the tracking code.
  5. Open the template descriptor file associated with your publishing template.
  6. Use the webhelp.fragment.after.body parameter in the html-fragments section of the descriptor file. Set the value of that parameter to reference the googleAnalytics.xml file that you created earlier. The content of this file will be copied at the end of all generated output pages, right before the ending <body> element. This ensures that the page is loaded before the Google Analytics servers are contacted, thus reducing page loading time.
    <publishing-template>
        ...
        <webhelp>
            ...                
          <html-fragments>
            <fragment 
              file="HTML-fragments/googleAnalytics.xml" 
              placeholder="webhelp.fragment.after.body"/>
          </html-fragments>
        </webhelp>
  7. Open the DITA Map WebHelp Responsive transformation scenario.
  8. Click the Choose Custom Publishing Template link and select your template.
  9. Click OK to save the changes to the transformation scenario.
  10. Run the transformation scenario.

Using a Transformation Scenario in Oxygen XML Editor/Author

To integrate Google Analytics into your WebHelp Responsive output using a transformation scenario from within Oxygen XML Editor/Author, follow this procedure:
  1. Create a new Google Analytics account (if you do not already have one) and log on.
  2. Choose the Analytics solution that best fits the needs of your website.
  3. Follow the on-screen instructions to obtain a Tracking Code that contains your Tracking ID. A Tracking Code looks like this:
    <script>
     (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
     (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
     m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
     })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
    
     ga('create', 'UA-XXXXXXXX-X', 'auto');
     ga('send', 'pageview');
    </script>
  4. Save the Tracking Code (obtained in the previous step) in a new XML file called googleAnalytics.xml. Note that the file should only contain the tracking code.
  5. Edit the DITA Map WebHelp Responsive transformation scenario and choose a template.
  6. Switch to the Parameters tab. Edit the webhelp.fragment.after.body parameter and set it to reference the googleAnalytics.xml file that you created earlier. The content of this file will be copied at the end of all generated output pages, right before the ending <body> element. This ensures that the page is loaded before the Google Analytics servers are contacted, thus reducing page loading time.
  7. Click Ok and run the transformation scenario.