SEO for Raw Traffic

Optimizing a site for search engines and creating keyword-targeted content helps a site rank
for key search terms, which typically leads to direct traffic and referring links as more and more
people find, use, and enjoy what you’ve produced. Thousands of sites on the Web leverage
this traffic to serve advertising, directly monetizing the traffic sent from the engines. From
banner ads to contextual services such as Google’s AdSense program to affiliate programs and
beyond, web advertising has become a massive industry—$25 billion plus, according to
eMarketer.

Here are some factors to think about when considering SEO for raw traffic:
When to employ
Use it when you can monetize traffic without actions or financial transactions on your site
(usually through advertising).
Keyword targeting
Keyword targeting in this scenario can be very broad. The goal here isn’t typically to select
specific keywords, but rather to create lots of high-quality content that naturally targets
interesting/searched-for terms. Instead of singular optimization on specific terms, the
focus is on accessibility and best practices throughout the site to earn traffic through both
high volume and long tail queries (for more on what long tail is, see Chapter 5).
Concentrate efforts on great content, and use keyword-based optimization only as a
secondary method to confirm the titles/headlines of the works you create.
Page and content creation/optimization
A shallow, highly crawlable link structure is critical to getting all of your content indexed—
follow good information architecture practices.You’ll also need to
employ good on-page optimization (titles, headlines, internal linking, etc.) and make your
articles easy to share and optimized for viral spreading.

SEO for Reputation Management

SEO for reputation management is a process for neutralizing negative mentions of your name
in the SERPs. In this type of SEO project, you would strive to occupy additional spots in the
top 10 results to push the critical listing lower and hopefully off the first page. You may
accomplish this using social media, major media, bloggers, your own sites and subdomains,
and various other tactics.


Since one’s own name—whether personal or corporate—is one’s identity, establishing and
maintaining the reputation associated with that identity is generally of great interest.
Imagine that you search for your brand name in a search engine and high up in the search
results is a web page that is highly critical of your organization.

SEO for E-Commerce Sales

One of the most direct monetization strategies for SEO is driving relevant traffic to an ecommerce
shop to boost sales. Search traffic is among the best quality available on the Web,
primarily because a search user has expressed a specific goal through her query, and when this
matches a product or brand the web store carries, conversion rates are often extremely high.

When to employ
Use it when you have products/services that are directly for sale on your website.
Keyword targeting
Paid search advertising is an excellent way to test the efficacy and potential ROI of keyword
targets. Find those that have reasonable traffic and convert well, and then pursue them
further. You’ll often find that the more specific the query—brand-inclusive, productinclusive,
and so on—the more likely the visitors are to make the purchase.
Page and content creation/optimization
You’ll typically need some serious link building, along with internal optimization, to
achieve high rankings for competitive, high-value keywords that bring in conversionfocused
traffic. Manual link building is an option here, but scalable strategies that leverage
a community or customers can be equally, or even more, valuable.

Javascript Math object

The Math object holds a set of constants and methods enabling more complex mathematical operations than the basic arithmetic operators

var root = Math.sqrt(10);


Constants Provided by the Math Object
Property
Description
Math.E
The base of the natural logarithm (Euler's constant e)
Math.LN2
Natural log of 2
Math.LN10
Natural log of 10
Math.LOG2E
Log (base 2) of e
Math.LOG10E
Log (base 10) of e
Math.PI
Pi (p)
Math.SQRT1_2
Square root of 0.5 (equivalently, one over the square root of 2)
Math.SQRT2
Square root of 2
Table 7-4: Methods Provided by the Math Object
Method
Returns
Math.abs(arg)
Absolute value of arg
Math.acos(arg)
Arc cosine of arg
Math.asin(arg)
Arc sine of arg
Math.atan(arg)
Arc tangent of arg
Math.atan2(y, x)
Angle between the x axis and the point (x, y), measured counterclockwise (like polar coordinates). Note how y is passed as the first argument rather than the second.
Math.ceil(arg)
Ceiling of arg (smallest integer greater than or equal to arg)
Math.cos(arg)
Cosine of arg
Math.exp(arg)
e to arg power
Math.floor(arg)
Floor of arg (greatest integer less than or equal to arg)
Math.log(arg)
Natural log of arg (log base e of arg)
Math.max(arg1, arg2)
The greater of arg1 or arg2
Math.min(arg1, arg2)
The lesser of arg1 or arg2
Math.pow(arg1, arg2)
arg1 to the arg2 power
Math.random()
A random number in the interval [0,1]
Math.round(arg)
The result of rounding arg to the nearest integer. If the decimal portion of arg is greater than or equal to .5, it is rounded up. Otherwise, arg is rounded down.
Math.sin(arg)
Sine of arg
Math.sqrt(arg)
Square root of arg
Math.tan(arg)
Tangent of arg
There are several aspects of the Math object that need to be kept in mind. The trigonometric methods work in radians, so you need to multiply any degree measurements by p / 180 before using them. Also, because of the imprecise characteristic of floating-point operations, you might notice minor deviations from the results you expect. For example, though the sine of p is 0, the following code:
alert(Math.sin(Math.PI));

JavaScript and XML

To demonstrate JavaScript, XML, and the DOM in action, let’s use Internet Explorer 5.5 or better to load an XML document containing our employee directory and see if we can manipulate it. First, to load in the document we create an instantiation of Microsoft’s XML parser using the JScript-specific ActiveXobject. Once the object is created, we load the appropriate XML document into memory. In this case, it is the pure XML file of employee records we saw earlier without style sheets or other references.
var xmldoc = new ActiveXObject("Microsoft.XMLDOM");

xmldoc.async = false;

xmldoc.load("staff2.xml");
Once loaded, we can then use the DOM to manipulate it. For example, we can access the root element of the document (<<directory>>) using
var rootElement = xmldoc.documentElement;
then we might alert out its nodeName property as shown in this example.
<<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">>

<<html xmlns="http://www.w3.org/1999/xhtml">>

<<head>>

<<title>>XML Demo<</title>>

<<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />>

<</head>>

<<body>>

<<script type="text/jscript">>

<<!--

 var xmldoc = new ActiveXObject("Microsoft.XMLDOM");

 xmldoc.async = false;

 xmldoc.load("staff.xml");



 var rootElement = xmldoc.documentElement;

//-->>

<</script>>

<<form action="#" method="get">>

 <<input type="button" value="show node"

 onclick="alert(rootElement.nodeName);" />>

<</form>>

<</body>>

<</html>>
 
 
 
 
 
 
function deleteLastElement()

{

  var rootElement = xmldoc.documentElement;

  if (rootElement.hasChildNodes())

     rootElement.removeChild(rootElement.lastChild);

}
 
 
 
Really the only difference here is the use of the xmldoc object we created to reference the XML document rather than just plain document, which would reference the HTML Document object. Otherwise, the manipulations are the same as with HTML.
 

Javascript Image Objects

Properties of Image Objects
Property
Description
align
Indicates the alignment of the image, usually “left” or “right.”
alt
The alternative text rendering for the image as set by the alt attribute.
border
The width of the border around the image in pixels.
complete
Non-standard (but well-supported) Boolean indicating whether the image has completed loading.
height
The height of the image in pixels or as a percentage value.
hspace
The horizontal space around the image in pixels.
isMap
Boolean value indicating presence of the ismap attribute, which indicates the image is a server-side image map. The useMap property is used more often today.
longDesc
The value of the (X)HTML longdesc attribute, which provides a more verbose description for the image than the alt attribute.
lowSrc
The URL of the “low source” image as set by the lowsrc attribute. Under early browsers, this is specified by the lowsrc property.
name
The value of the name attribute for the image.
src
The URL of the image.
useMap
The URL of the client-side image map if the <img> tag has a usemap attribute.
vspace
The vertical space in pixels around the image.
width
The width of the image in pixels or as a percentage value.
The traditional Image object also supports onabort, onerror, and onload event handlers. The onabort handler is invoked when the user aborts the loading of the image, usually by clicking the browser’s Stop button. The onerror handler is fired when an error occurs during image loading. The onload handler is, of course, fired once the image has loaded. Under modern browser implementations that support (X)HTML properly, you will also find onmouseover, onmouseout, onclick, and the rest of the core events supported for Image.

Javascript The + Operator

The binary + operator adds numeric operands or concatenates string operands:

1 + 2 // => 3
"hello" + " " + "there" // => "hello there"
"1" + "2" // => "12"

When the values of both operands are numbers, or are both strings, then it is obvious
what the + operator does. In any other case, however, type conversion is necessary, and
the operation to be performed depends on the conversion performed. The conversions
rules for + give priority to string concatenation: if either of the operands is a string or
an object that converts to a string, the other operand is converted to a string and concatenation
is performed.

Javascript Recursion

Recursion is when a function calls itself. This is often useful in mathematics,
such as fi nding the nth number in the Fibonacci series (1, 2, 3, 5,
8, 13, 21…).
function fi bonacci(n) {
if ( n < 2 ) {
return 1;
} else {
return fi bonacci(n-2) + fi bonacci(n-1);
}
}
fi bonacci(5);
8
fi bonacci(10);
89

Javascript Objects as Arguments

You may want to write functions that take many arguments, some of
which are optional.
function drawElement( color, border, width, height,
left, top, zIndex) {
// Make and display an element with these variables
}
drawElement("red", 4, null, null, 100, 10);
Function signatures like this aren’t ideal for a couple of reasons:
■ It’s hard to remember the exact order of arguments.
■ You have to specify null values when you want to use the default
value for arguments in the middle of the signature.
■ Did you notice that I forgot to specify a value for zIndex? It’s hard to
count all those arguments correctly!
Passing multiple values in a single object is often a better solution:
function drawElement(options) {
// Make and display an element with the values in options
}
drawElement({
color: "red",
border: 4,
left: 100,
top: 10
});
Specifying default values is a little bit trickier with this technique. You’ll
need to create an object holding all the defaults and merge it with the
options object.

Javascript search

search(regexp)
The search() method is the same as indexOf() except that it takes a
regular expression pattern instead of a substring. It also returns -1 if the
pattern isn’t found.
"hello world".search(/[aeiou]/); // Find the fi rst vowel
1
"hello world".search(/\d/); // Find the fi rst digit
-1
match(regexp)
The match() method returns an array containing all the substrings
matching the regular expression and its subpatterns. Unlike the other
search-and-replace methods, it returns null if the pattern doesn’t match.
Here are some simple examples, but I’ll cover this function more in
Chapter 8:
// Find all the vowels
"hello world".match(/[aeiou]/g);
["e", "o", "o"]
// Find "world" regardless of capitalization
"hElLo WoRlD".match(/world/i);
["WoRlD"]
replace(pattern, replacement)
The replace() method works like match() except that it returns a string
with all instances of pattern replaced by the string replacement.
// Remove all non-numeric characters from a phone number
"(310) 555-9876".replace(/\D/g, "");