1

I've put some objects in an S3 bucket and I want to log everytime a client makes a request to one of those objects.

I'm using Umbraco 4.8 as my back-end with some custom code running.

The solutions I've come up with:

  1. Set the link to an ASP page that pulls the object from S3 and sends it back as the response. The problem I see there is then the client has to wait for ASP to load the file before it can begin downloading the file.

  2. Set the link to an ASP page that logs the request and returns a Response.Redirect to the S3 object. To me this seems like an unnecessary redirect and the client might cache that redirect and not hit my server the next time they access that object.

Does anyone have any other solutions or thoughts on how to achieve this? Any help would be appreciated.

4

2 に答える 2

1

私はjqueryとgoogleanalyticsを使用します。追跡する各リンクにクラスを追加し、jqueryを使用してonclickイベントを次のように操作します。

<a href="[link]" onclick="__gaq.push(['_trackEvent', 's3-Bucket-Request', 's3-actual-bucket-name', 'current-page']);">link text</a>

3つの変数を適切に置き換えます(「s3-Bucket-Request」、「s3-actual-bucket-name」、「current-page」)。次に、各ページの先頭にjqueryを配置すると、再利用可能な関数が得られます。

始める:

<a href="[link]" class="ga">link text</a> 

jquery:

$('.ga').attr("onclick", "__gaq.push(['_trackEvent', 's3-Bucket-Request', 's3-actual-bucket-name', 'current-page']);");

終わり:

<a href="[link]" class="ga" onclick="__gaq.push(['_trackEvent', 's3-Bucket-Request', 's3-actual-bucket-name', 'current-page']);">link text</a>
于 2012-09-17T09:41:51.233 に答える
0

これがどれだけ正確であるかに応じて、クライアント側でも行うことができます。jQuery などを使用a hrefして、コントローラに ajax リクエストを行い、アクティビティをログに記録するタグにクリック ハンドラを追加します。

于 2012-09-14T22:03:52.143 に答える