Thomas Deselaers
2009-Nov-30 12:53 UTC
[webgen-users] webgen, downloads and google analytics
Dear all, Maybe someone (Thomas?) has an idea how to achieve this. I log traffic to my website using google analytics. Now I would like to also count the downloads of files. Google describes that this can be done by adding a javascript-snippet to each download link: http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55529 Can someone tell me, how I could automatically have something similar attached to every non-html-link in my page? Cheers, Thanks, thomas -- http://thomas.deselaers.de
Thomas Leitner
2009-Nov-30 15:01 UTC
[webgen-users] webgen, downloads and google analytics
> I log traffic to my website using google analytics. Now I would like > to also count the downloads of files. > > Google describes that this can be done by adding a javascript-snippet > to each download link: > > http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55529 > > Can someone tell me, how I could automatically have something similar > attached to every non-html-link in my page?Hmm... if this is something static for each file, you could just use the `link_attrs` meta information. For example, say you have a file src/download/my.pdf. Then add a metainfo file src/download/metainfo with the following content: --- name:alcn my.pdf: link_attrs: onClick: "javascript: pageTracker._trackPageview(''/downloads/map'');" Then every link generated by webgen (for example, via the menu, breadcrumb trail and link tags) will have an `onClick` attribute with the specified value. From what I read from the provided page, the `/downloads/map` part has to be different for each file. Since webgen doesn''t allow dynamic code in the `link_attrs` meta information, you would need to set this meta information for all files manually. Or you overwrite the Node#link_to method in an extension to dynamically generate the `onClick` attribute. -- Thomas
Thomas Deselaers
2009-Nov-30 17:34 UTC
[webgen-users] webgen, downloads and google analytics
On Mon, Nov 30, 2009 at 16:01, Thomas Leitner <t_leitner at gmx.at> wrote:>> I log traffic to my website using google analytics. Now I would like >> to also count the downloads of files. >> >> Google describes that this can be done by adding a javascript-snippet >> to each download link: >> >> http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55529 >> >> Can someone tell me, how I could automatically have something similar >> attached to every non-html-link in my page? > > Hmm... if this is something static for each file, you could just use > the `link_attrs` meta information.That sounds great.> For example, say you have a file src/download/my.pdf. Then add a > metainfo file src/download/metainfo with the following content: > > --- name:alcn > my.pdf: > ?link_attrs: > ? ?onClick: "javascript: pageTracker._trackPageview(''/downloads/map'');"I added this for one of the PDFs, but the generated html files are not changed at all. Do I have to mark the links in a special way. here is a snippet from my list [from publications/index.page]: * Thomas Deselaers, Daniel Keysers, and Hermann Ney. [Features for Image Retrieval: An Experimental Comparison]. In: Information Retrieval 11.2 (2008), pp. 77-107. [Features for Image Retrieval: An Experimental Comparison]: papers/deselaers_infret08.pdf then I have this in my metainfo file: /publications/papers/deselaers_infret08.pdf: link_attrs: {onClick: "javascript: pageTracker._trackPageview(''/downloads/belle_icpr08'');"} and of course the publications/papers/deselaers_infret08.pdf file exists. Oh, and to let you know, I already switched to this new page for my personal webpage. webgen is really very convenient and much easier and faster to learn than any of the other tools I used before. Tahnks a lot. thomas> Then every link generated by webgen (for example, via the menu, > breadcrumb trail and link tags) will have an `onClick` attribute with > the specified value. > > >From what I read from the provided page, the `/downloads/map` part has > to be different for each file. Since webgen doesn''t allow dynamic code > in the `link_attrs` meta information, you would need to set this meta > information for all files manually. Or you overwrite the Node#link_to > method in an extension to dynamically generate the `onClick` attribute. > > -- Thomas > _______________________________________________ > webgen-users mailing list > webgen-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/webgen-users >-- http://thomas.deselaers.de
Thomas Deselaers
2009-Nov-30 21:43 UTC
[webgen-users] webgen, downloads and google analytics
On Mon, Nov 30, 2009 at 18:34, Thomas Deselaers <thomas at deselaers.de> wrote:> On Mon, Nov 30, 2009 at 16:01, Thomas Leitner <t_leitner at gmx.at> wrote: >>> I log traffic to my website using google analytics. Now I would like >>> to also count the downloads of files. >>> >>> Google describes that this can be done by adding a javascript-snippet >>> to each download link: >>> >>> http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55529 >>> >>> Can someone tell me, how I could automatically have something similar >>> attached to every non-html-link in my page? >> >> Hmm... if this is something static for each file, you could just use >> the `link_attrs` meta information. > > That sounds great. > >> For example, say you have a file src/download/my.pdf. Then add a >> metainfo file src/download/metainfo with the following content: >> >> --- name:alcn >> my.pdf: >> ?link_attrs: >> ? ?onClick: "javascript: pageTracker._trackPageview(''/downloads/map'');" > > > I added this for one of the PDFs, but the generated html files are not > changed at all. > > > Do I have to mark the links in a special way. > > here is a snippet from my list > > [from publications/index.page]: > * ?Thomas Deselaers, Daniel Keysers, and Hermann Ney. > ? [Features for Image Retrieval: An Experimental Comparison]. > ? In: Information Retrieval ?11.2 (2008), pp. 77-107. > ? [Features for Image Retrieval: An Experimental Comparison]: > papers/deselaers_infret08.pdf > > then I have this in my metainfo file: > > /publications/papers/deselaers_infret08.pdf: > ? link_attrs: > ? ? ?{onClick: "javascript: > pageTracker._trackPageview(''/downloads/belle_icpr08'');"} > > and of course the > publications/papers/deselaers_infret08.pdf > file exists. > > > Oh, and to let you know, I already switched to this new page for my > personal webpage. > webgen is really very convenient and much easier and faster to learn > than any of the other tools I used before.Hi Thomas and others, I played a bit more with it. Unfortunately I didn''t manage to make it work. I have tried various variations in which metainfo file [directly in src, in a subdirectory, and in the subdirectory in which the files that I link to reside], but none of them works. however, I found a way to generate an appropriate metainfo file fully automatically: (echo "--- name:alcn"; for i in *.pdf ; do echo -e "$i:\n link_attrs:\n onClick: \"javascript:pageTracker._trackPageview(''publications/papers/$i'')\"\n\n" ; done) > metainfo Then I also tried to make the link relocatable. That works fine, but it did not help to get the link attributes set. So, your help is greatly appreciated. Thanks, thomas -- http://thomas.deselaers.de
Thomas Leitner
2009-Dec-01 07:14 UTC
[webgen-users] webgen, downloads and google analytics
> Do I have to mark the links in a special way. > > here is a snippet from my list > > [from publications/index.page]: > * Thomas Deselaers, Daniel Keysers, and Hermann Ney. > [Features for Image Retrieval: An Experimental Comparison]. > In: Information Retrieval 11.2 (2008), pp. 77-107. > [Features for Image Retrieval: An Experimental Comparison]: > papers/deselaers_infret08.pdfAs said in the other mail: only those links that are *generated* by webgen will be changed! For example, if you use a [Markdown link](some.pdf) the link is not generated by webgen and therefore this facility can''t kick in. However, if you use the link tag, then the link is generated by webgen and it will work.> then I have this in my metainfo file: > > /publications/papers/deselaers_infret08.pdf: > link_attrs: > {onClick: "javascript: > pageTracker._trackPageview(''/downloads/belle_icpr08'');"} > > and of course the > publications/papers/deselaers_infret08.pdf > file exists.This looks fine.> webgen is really very convenient and much easier and faster to learn > than any of the other tools I used before.Thanks! Most people find the current documentation lacking and I have to admit, it is not as clear as it could be. However, it''s good to hear otherwise! -- Thomas
Thomas Leitner
2009-Dec-01 08:51 UTC
[webgen-users] webgen, downloads and google analytics
> however, I found a way to generate an appropriate metainfo file fully > automatically: > (echo "--- name:alcn"; for i in *.pdf ; do echo -e "$i:\n > link_attrs:\n onClick: > \"javascript:pageTracker._trackPageview(''publications/papers/$i'')\"\n\n" > ; done) > metainfoCool :-) You could create a new task in the Rakefile sothat this will always be executed before webgen renders the site, something like: task :generate_metainfo do sh ''YOUR CODE GOES HERE'' end task :webgen => [:generate_metainfo]> Then I also tried to make the link relocatable. That works fine, but > it did not help to get the link attributes set.The relocatable tag only outputs the relativized path, but not a full link. As mentioned in the other post, you need to use something like the link tag! -- Thomas
Thomas Deselaers
2009-Dec-01 09:58 UTC
[webgen-users] webgen, downloads and google analytics
On Tue, Dec 1, 2009 at 08:14, Thomas Leitner <t_leitner at gmx.at> wrote: Hi,>> [from publications/index.page]: >> * ?Thomas Deselaers, Daniel Keysers, and Hermann Ney. >> ? ?[Features for Image Retrieval: An Experimental Comparison]. >> ? ?In: Information Retrieval ?11.2 (2008), pp. 77-107. >> ? ?[Features for Image Retrieval: An Experimental Comparison]: >> papers/deselaers_infret08.pdf > > As said in the other mail: only those links that are *generated* by > webgen will be changed! For example, if you use a [Markdown > link](some.pdf) the link is not generated by webgen and therefore this > facility can''t kick in. However, if you use the link tag, then the link > is generated by webgen and it will work.Ah. That was not clear to me. The connection between markdown and webgen was not so obvious. This now allowed me also to avoid the metainfo file: e.g. using this snippet: * Thomas Deselaers, Daniel Keysers, and Hermann Ney. {link: {path: papers/deselaers_infret08.pdf, attr: {onClick: "javascript: pageTracker._trackPageview(''publications/papers/deselaers_infret08.pdf'');", :link_text: "Features for Image Retrieval: An Experimental Comparison"}}} In: Information Retrieval 11.2 (2008), pp. 77-107. This nearly works (and leads to the same result as the solution using a metainfo file). The generated HTML looks like that: <li> <p>Thomas Deselaers, Daniel Keysers, and Hermann Ney. <a href=''papers/deselaers_infret08.pdf'' onClick=''javascript: pageTracker._trackPageview('publications/papers/deselaers_infret08.pdf');''>Features for Image Retrieval: An Experimental Comparison</a> In: Information Retrieval 11.2 (2008), pp. 77-107.</p> </li> where unfortunately the apostroph-quotes are broken. I already tried some other ways of quoting the string, but I couldn''t find one that works.> This looks fine. > >> webgen is really very convenient and much easier and faster to learn >> than any of the other tools I used before. > > Thanks! Most people find the current documentation lacking and I have > to admit, it is not as clear as it could be. However, it''s good to hear > otherwise!Well, the documentation is not super clear, but there is the code, and this is not too hard to understand although I never saw ruby before (but lots of other programming languages). I also refered to the webgen website sources from the git repostitory quite a bit. Maybe you could add pointers to it from the documentation. And finally, a valueable resource is the discussion on the mailinglist, once I figured out that some things changed massively from version 4.x to 5.10 ;-) I also guess, that instead of a very formal description of the features, examples of its usage are very helpfull Cheers, thomas -- http://thomas.deselaers.de
Thomas Leitner
2009-Dec-01 11:20 UTC
[webgen-users] webgen, downloads and google analytics
> The generated HTML looks like that: > > <li> > <p>Thomas Deselaers, Daniel Keysers, and Hermann Ney. <a > href=''papers/deselaers_infret08.pdf'' onClick=''javascript: > pageTracker._trackPageview('publications/papers/deselaers_infret08.pdf');''>Features > for Image Retrieval: An Experimental Comparison</a> In: Information > Retrieval 11.2 (2008), pp. 77-107.</p> > </li> > > where unfortunately the apostroph-quotes are broken.This is probably a problem with Maruku parsing the generated `<a>` tag and substituting ' for `''`. However, this should not be a problem, I guess, since the browser will substitute the entity back to the real character before passing the script to Javascript but I''m not sure on this.> I also guess, that instead of a very formal description of the > features, examples of its usage are very helpfullPutting more examples on the website is on my (long) TODO list. -- Thomas
Thomas Deselaers
2009-Dec-01 12:16 UTC
[webgen-users] webgen, downloads and google analytics
Sorry, this email was intended to go to the list. On Tue, Dec 1, 2009 at 12:20, Thomas Leitner <t_leitner at gmx.at> wrote: Hi,>> The generated HTML looks like that: >> >> <li> >> <p>Thomas Deselaers, Daniel Keysers, and Hermann Ney. <a >> href=''papers/deselaers_infret08.pdf'' onClick=''javascript: >> pageTracker._trackPageview('publications/papers/deselaers_infret08.pdf');''>Features >> for Image Retrieval: An Experimental Comparison</a> In: Information >> Retrieval 11.2 (2008), pp. 77-107.</p> >> </li> >> >> where unfortunately the apostroph-quotes are broken. > > This is probably a problem with Maruku parsing the generated `<a>` tag > and substituting ' for `''`. However, this should not be a problem, > I guess, since the browser will substitute the entity back to the real > character before passing the script to Javascript but I''m not sure on > this.Indeed, it seems to be working. I am quite surprised about this. To check whether firefox accepts this, I created a small test case: ----------------------------8<---------------------------------- <script type="text/javascript"> <!-- function confirmation(mytext) { var answer = confirm(mytext) if (answer){ alert("Bye bye!") window.location = "http://www.google.com/"; } else{ alert("Thanks for sticking around!") } } //--> </script> Test link: {link: {path: papers/deselaers_infret08.pdf, attr: {onClick: "javascript:confirmation(''asdf'');", :link_text: "testlink"}}} ---------------------------------------->8---------------------------- resulting in the following HTML: ----------------------------8<---------------------------------- <script type=''text/javascript''> <!-- function confirmation(mytext) { var answer = confirm(mytext) if (answer){ alert("Bye bye!") window.location = "http://www.google.com/"; } else{ alert("Thanks for sticking around!") } } //--> </script> <p>Test link: <a href=''papers/deselaers_infret08.pdf'' onClick=''javascript:confirmation('asdf');''>testlink</a></p> ---------------------------------------->8---------------------------- which seems to be working just fine. So, now I will try to figure out how to apply this to all links automatically.>> I also guess, that instead of a very formal description of the >> features, examples of its usage are very helpfull > > Putting more examples on the website is on my (long) TODO list.;-) Well, I guess, it might already help to put some text on the webgen site asking people who use webgen to provide their sources in some kind of repository. That would have your userbase generate the examples. ;-) Cheers, Thanks a lot... thomas -- http://thomas.deselaers.de -- http://thomas.deselaers.de
Thomas Deselaers
2009-Dec-02 09:23 UTC
[webgen-users] webgen, downloads and google analytics
Hi everybody, just to keep you up to date. It really works that way, so, I now use link tags and metainfo files specifying the link_attr for each of the files to be downloaded. The metainfo files are automatically generated... with a slightly extended version of the one-line script I sent previously. cheers, thomas On Tue, Dec 1, 2009 at 13:16, Thomas Deselaers <thomas at deselaers.de> wrote:> Sorry, this email was intended to go to the list. > > On Tue, Dec 1, 2009 at 12:20, Thomas Leitner <t_leitner at gmx.at> wrote: > > Hi, > >>> The generated HTML looks like that: >>> >>> <li> >>> <p>Thomas Deselaers, Daniel Keysers, and Hermann Ney. <a >>> href=''papers/deselaers_infret08.pdf'' onClick=''javascript: >>> pageTracker._trackPageview('publications/papers/deselaers_infret08.pdf');''>Features >>> for Image Retrieval: An Experimental Comparison</a> In: Information >>> Retrieval 11.2 (2008), pp. 77-107.</p> >>> </li> >>> >>> where unfortunately the apostroph-quotes are broken. >> >> This is probably a problem with Maruku parsing the generated `<a>` tag >> and substituting ' for `''`. However, this should not be a problem, >> I guess, since the browser will substitute the entity back to the real >> character before passing the script to Javascript but I''m not sure on >> this. > > Indeed, it seems to be working. I am quite surprised about this. > > To check whether firefox accepts this, I created a small test case: > > ----------------------------8<---------------------------------- > <script type="text/javascript"> > <!-- > function confirmation(mytext) { > var answer = confirm(mytext) > if (answer){ > alert("Bye bye!") > window.location = "http://www.google.com/"; > } > else{ > alert("Thanks for sticking around!") > } > } > //--> > </script> > > Test link: {link: {path: papers/deselaers_infret08.pdf, attr: > {onClick: "javascript:confirmation(''asdf'');", :link_text: > "testlink"}}} > ---------------------------------------->8---------------------------- > > resulting in the following HTML: > ----------------------------8<---------------------------------- > <script type=''text/javascript''> > <!-- > function confirmation(mytext) { > var answer = confirm(mytext) > if (answer){ > alert("Bye bye!") > window.location = "http://www.google.com/"; > } > else{ > alert("Thanks for sticking around!") > } > } > //--> > > </script> > <p>Test link: <a href=''papers/deselaers_infret08.pdf'' > onClick=''javascript:confirmation('asdf');''>testlink</a></p> > ---------------------------------------->8---------------------------- > > which seems to be working just fine. > > So, now I will try to figure out how to apply this to all links automatically. > > > >>> I also guess, that instead of a very formal description of the >>> features, examples of its usage are very helpfull >> >> Putting more examples on the website is on my (long) TODO list. > > ;-) > Well, I guess, it might already help to put some text on the webgen > site asking people who use webgen to provide their sources in some > kind of repository. > > That would have your userbase generate the examples. ;-) > > Cheers, Thanks a lot... > thomas > > > > > > -- > http://thomas.deselaers.de > > > > > -- > http://thomas.deselaers.de >-- http://thomas.deselaers.de