Showing posts with label Blogspot. Show all posts
Showing posts with label Blogspot. Show all posts

Sunday, July 19, 2009

Blogger: Exclude Your Visits from Google Analytics

Google Analytics has a way of excluding certain visits to a site based on the presence of a special cookie. Many resources suggest that you create a "hidden" Web page to accomplish this, but that's difficult to do with Blogger. There is a workaround, however.

First, make sure you have Google Analytics installed and running on your blog.

Next, from each Web browser you use, pull up your blog. Once the page has fully loaded, enter the following javascript in the browser's location bar and press return/enter:
javascript:pageTracker._setVar('notrack');alert('cookie set');
That will set a "notrack" cookie on your browser.

Finally, sign into your Google Analytics account and create a custom filter to exclude all visitors that have the "notrack" cookie set. The filter values should be:

Filter Type: Custom filter > Exclude
Filter Field: User Defined
Filter Pattern: notrack
Case Sensitive: No
Google Analytics should now begin ignoring your visits.

This approach isn't specific to Blogger; it should work on any site, including other blogging platforms such as Wordpress and Movable Type.

Also, to make it simpler to set the cookie, you may want to create a bookmark with the above javascript. Once added, simply go to your blog and select the bookmark.

Keywords: blogger ignore visits, blogger exclude, blogger hide

Saturday, January 13, 2007

Table Formatting in Blogger

I'm pretty new to Blogger but one of the first snags I hit was with formatting tables due to the way Blogger automatically inserts line breaks. You can disable that behavior under Settings but it's a global option so it affects all posts. Another option is to write your tables without line breaks, but that's a maintenance problem.

Here's another approach that works (tested with Firefox 1.5 and IE 6; anyone have other browser results?). At the top of your post add this:

<style type="text/css">.nobr br { display: none }</style>

Then place your table within that class:
<div class="nobr">
<table border="1">
<tr>
<td>GOOG</td>
<td>505.00</td>
<td>2006-01-12</td>
</tr>
<tr>
<td>BRK-A</td>
<td>110,000.00</td>
<td>2006-01-12</td>
</tr>
</table>
</div>
That has the effect of turning off the display of the Blogger-generated line breaks within the div, causing the table to be rendered properly.

Here's how that table looks in your browser:













GOOG 505.00 2006-01-12
BRK-A 110,000.00 2006-01-12


I think it should be possible to move the CSS declaration into the template so you don't have to repeat it in each post.

Note from reader S.B.:
Unfortunately, both the "Compose" and "Preview" views of a post still render incorrectly, but when you actually publish, the table does come out right!