Link

Track page views in the IDRViewer with Google Analytics

To get Google Analytics to work with the IDRViewer, you can use the following code examples to add to the index.html file generated. All you need to do is add the example code into the index.html just above the closing </body> tag and then replace the G-XXXXXXXX sections with your Google Analytics Tracking code (check here if you need help getting this).

gtag.js:

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXX"></script>
<script>
    (function() {
        window.dataLayer = window.dataLayer || [];

        function gtag() {
            dataLayer.push(arguments);
        }

        gtag('js', new Date());

        gtag('config', 'G-XXXXXXXX');

        function trackPageView(page) {
            gtag('config', 'G-XXXXXXXX', {
                'page_path': location.pathname + '?page=' + page
            });
        }

        var THRESHOLD = 1000; // Length of time (in millis) required on page to be considered a pageview
        var lastPage;
        IDRViewer.on('pagechange', function (data) {
            lastPage = data.page;
            setTimeout(function () { // Wait until the page stops changing until sending page view
                if (lastPage === data.page) {
                    trackPageView(data.page);
                }
            }, THRESHOLD);
        });
    })();
</script>
<!-- Global site tag ends -->

What's included in your BuildVu trial?

  • Access to download the SDK and run it locally.
  • Access to the cloud trial to convert documents in the IDR cloud.
  • Access to the Docker image to set up your own trial server in the cloud.
  • Communicate with IDR developers to ask questions & get expert advice.
  • Plenty of time to experiment and build a proof of concept.
  • Over 100 articles to help you get started and learn about BuildVu.
  • An exceptional PDF to HTML converter that took over 20 years to build!

Start Your Free Trial