Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include Google Analytics snippet in Javadoc?

I would like to include the Google Analytics Javascript code in the head element of my generated Javadoc HTML output. How can I do this?

I figured I may need to write a custom Doclet, but this is probably going to be a nightmare of a learning curve. Isn't there a simpler way?

like image 262
Christian Schlichtherle Avatar asked Nov 25 '25 11:11

Christian Schlichtherle


2 Answers

Use CData

<configuration>
    <!-- GA Tracking code -->
    <header>
    <![CDATA[
        <script type="text/javascript">
          var _gaq = _gaq || [];
          _gaq.push(['_setAccount', 'UA-XXXXXXXX-1']);
          _gaq.push(['_trackPageview']);

          (function() {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
          })();

        </script>
    ]]>
    </header>
</configuration>
like image 71
Joseph Lust Avatar answered Nov 28 '25 00:11

Joseph Lust


You have 2 solutions, Using maven plugin Javadoc with

<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <configuration>
                    <header>&lt;b&gt;test test&lt;/b&gt</header>    
            </configuration>
        </plugin>
    </plugins>
</reporting>

you change my "test test" with your google analytics script and don't forget to change < with < and > with > and then you call

mvn clean javadoc:javadoc

or using the old method http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#header with your html script

like image 27
nihed Avatar answered Nov 28 '25 02:11

nihed



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!