
321 - CREATE A FIREFOX KEYWORD TO SKIP THE ANALYTICS LOGIN BOX
HaCK
# 132
If on the other hand you host all module content within the module code itself, you can make use of
a special Google Analytics library available for gadgets. You can then make a call to track page views,
or to track specic events in your module, like clicks (please note that some attributes necessary to
submit your gadget to the directory, like the author email, have been omitted from this example; see
for a more complete example):
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="A Clickable Div!" ... >
<Require feature="analytics" />
</ModulePrefs>
<Content type="html">
<![CDATA[
<script type="text/javascript">
// This line tracks the gadget in Google Analytics
_IG_Analytics("YOUR_ANALYTICS_ID", "/mygadget");
</script>
<div onclick="_IG_Analytics('YOUR_ANALYTICS_ID', '/mygadget/click')">
Clicks on this div will be tracked
</div>
]]>
</Content>
</Module>
Note the three bold parts of this XML gadget code. First, the Require element prepares the gadget
for Google Analytics tracking. Second, a script element embeds a call to an Analytics function to
register the page view; the value /mygadget is a string that you can dene yourself that will be shown
as a path in Google Analytics reports. Third, the onclick event of the divisor element near the end of
the module ...