Categories
Web Development

Creating a Google Analytics Account

Google Analytics is a great tool, but it has some quirky aspects that must be understood if you are setting it up for anything but your own personal website.

For reasons nobody seems to be able to figure out, Google doesn't allow Analytics accounts to be transferred. This means that if you're setting up Google Analytics for a client or anyone else, you must not set it up with your own Google/Gmail account! And if you're hiring someone to do it for you, don't let them do so. The account must not be tied to any person, or used for any purpose other than the administration of your website or domain.

I've reached the conclusion that the only way to handle this is to create a dedicated GMail account for each client. Immediately set the mail to forward to an appopriate person(s), because you'll not often log into it. You can use this account to set up Google Analytics, AdSense, Google Apps, and anything else related to the website or domain.

Be sure to record the account name and password carefully and include the information in your handover package if doing this for a client. The domain name might be a good choice for the account name as it's easy to remember, i.e. "mydomain.com@gmail.com".

Once you've set up the new Google account, recorded its name and password, and set the mail forwarding, go to http://analytics.google.com. Make sure you're signed in with the new account.

A short series of questions will lead you to your tracking code.

The tracking code must be placed in each page to be tracked, so it's best to place it in the footer if you want all pages tracked. I choose the footer because I want the page to load before external actions are carried out. Page loads should not be delayed while tracking code accesses an external server.

Categories
Web Development

Placing an invisible validation link on a page

The HTML validator at http://validator.w3.org is a tremendous resource for web developers, helping us to ensure that our pages validate to the W3C standard.

Creating a Validation Link

Many developers place a link to the validator in the header or footer of their site so that they can demonstrate that their site is compliant.

1
<a href="http:///validator.w3.org/check/referer">Valid XHTML</a>

(The /check/referrer string tells the validator to validate what ever page the visitor came from)

Creating an Invisible Validation Link

Sometimes however, I like the link to be invisible, which I do be creating a link to a single non-breaking space entity. I use CSS to ensure that there is no underline and that the link doesn't stand out against a coloured background when the link is hovered over. Of course this means you have to know that there is an invisible hotspot at a certain point on the page. I often put it right after the text in my footer, as users don't often hover the mouse there. (All of this should be on on one line, I've put hard returns here only to keep it from scrolling out of the box.)

1
2
<a href="http:///validator.w3.org/check/referer" 
style="border-bottom: 0px;background-color:inherit;">&nbsp;</a>

Now there's an invisible validation link that I can have on my site throughout development for fast, easy validation checks. When the site goes live I can decide whether to leave it in or not.

Categories
WordPress

Limiting Revisions in WordPress

If you spend a lot of time revising a page or a post, you can build up quite a number of revisions in the database.

The following line in the wp-config.php file in the root of the site will limit the number of revisions saved to 5. You can use whatever number you want, within reason.

define('WP_POST_REVISIONS', 5);

Other tricks using the wp-config.php file can be found at http://digwp.com/2009/06/wordpress-configuration-tricks/.

Categories
DOS & DOS Scripting

Backup script

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
@echo off
rem :-----------------------------------------------------------------------------
rem : BACKUP SCRIPT
rem : This script was prepared for backing up a Windows XP computer
rem :   to an external hard drive.
rem : It will create a new folder named for the current date in the \backups folder of
rem :   the external drive, then copy the contents of the data folder on the computer.
rem : If the external drive ever fills up - unlikely - simply delete the oldest
rem :   folders from the backup folder to free up room.
rem : The script assumes that the external drive is drive letter K: and the
rem :   data folder on the source computer is "C:\Documents and Settings".
rem :-----------------------------------------------------------------------------

rem Set configuration - change these values if necessary
set backup_drive=K:
set source_folder=C:\Documents and Settings
 
title Data Backup

rem Remind the user to close all applications - open files may interfere
echo.
echo Preparing to backup computer data to external hard drive.
echo.
echo  - This backup may take several hours. It may best be done overnight.
echo  - All applications, including email, should be closed first.
echo.
echo Are you ready to proceed?
 
:loop
set Choice=
set /P Choice=Type [Y]es or [N]o and press Enter:
:: The syntax in the next line extracts the substring
:: starting at 0 (the beginning) and 1 character long
if not '%Choice%'=='' set Choice=%Choice:~0,1%
echo.
:: /I makes the IF comparison case-insensitive
if /I '%Choice%'=='y' goto proceed
if /I '%Choice%'=='n' goto skip
echo "%Choice%" is not valid. Please try again.
goto loop
 
:proceed
 
echo.
echo Proceeding with backup...

rem Change to backup drive and folder
cd /d %backup_drive%\backups

rem Create a folder for the current date and change to that directory
md %date:~-4,4%-%date:~-10,2%-%date:~-7,2%
cd %date:~-4,4%-%date:~-10,2%-%date:~-7,2%

rem Start the file copy
echo start &gt; start.txt
start /wait xcopy "%source_folder%" /E /C /H /R /Y
echo finish &gt; finish.txt

rem Advise user that backup is completed.
echo.
echo Backup is completed.
echo Files are stored at %backup_drive%\backup\%date:~-4,4%-%date:~-10,2%-%date:~-7,2%\
 
echo.
color 2f
 
goto end
 
:skip
echo.
echo All programs should be closed before this starts.
echo Please close all programs and try again.
goto end
 
:end
echo.
pause
Categories
Web Development

Color Schemes

Picking colors schemes (or colour schemes, in the Queen's English) can be difficult, and it's easy to fall into the bad habit of using the colors that have worked in the past.
The trick is to find a source for an online color scheme generator, which will let you browse through sets of complimentary colors to pick a color theme for your site.

Here are some great colour resources to help;

Keywords: color scheme, colour scheme, colour theme, color theme, colour set, colour set.