[GRADLE-178] Add Google Analytics snippet to the javadocs. Created: 09/Aug/08  Updated: 25/Mar/15  Resolved: 25/Mar/15

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: None

Type: Improvement
Reporter: Hans Dockter Assignee: Luke Daley
Resolution: Fixed Votes: 0


 Comments   
Comment by Jon Cox [ 22/Jan/09 ]

Can you explain this a bit more?

Comment by Hans Dockter [ 25/Jan/09 ]

This is a specific issue for the build of the Gradle project itself. When we generated the Javadoc for Gradle we could add a Google analytics script to every html page. That way we would get statistics how people use our javadocs. But it might be also an interesting generic feature.

Comment by Adam Murdoch [ 01/May/13 ]

Can we close this?

Comment by Peter Abeles [ 19/May/14 ]

I'm running into this issue now. Basically for google adsense or analytics you need to insert java script code into the JavaDoc. White spaces are important and you need to include newline characters. Here is an example of code which I need to inject:

------ BEGIN ------
<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1111111111-1']);
_gaq.push(['_setDomainName', 'foobar.org']);
_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>
------------- END ---------------

The Gradle build script looks something like this. I'm reading in the javascript from a file to avoid formatting issues:

------ BEGIN ------
task alljavadoc(type: Javadoc) {
...
configure(options)

{ ... header = file('misc/header.txt').text // header = file('misc/header.txt').text.replace("\n", ""); }

}
------------- END ---------------

The commented out line will remove all new line characters so that javadoc doesn't fail. However, when it does that it will break the javascript and it won't work.

Comment by Luke Daley [ 25/Mar/15 ]

Done a long time ago.

Generated at Wed Jun 30 11:23:39 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.