Google Analytics eCommerce Tracking

Here is the script that needs to be added to the receipt or confirmation page, after the user has completed the sale. You will just need to add php inside of the script so that the content can be created dynamically per customer. One tip is to use a PHP loop. Here is the code:

<script type="text/javascript">



ξ var _gaq = _gaq || [];

ξ _gaq.push(['_setAccount', 'UA-XXXXX-X']);

ξ _gaq.push(['_trackPageview']);

ξ _gaq.push(['_addTrans',

ξ ξ '1234', ξ ξ ξ ξ ξ // order ID - required

ξ ξ 'Acme Clothing', ξ// affiliation or store name

ξ ξ '11.99', ξ ξ ξ ξ ξ// total - required

ξ ξ '1.29', ξ ξ ξ ξ ξ // tax

ξ ξ '5', ξ ξ ξ ξ ξ ξ ξ// shipping

ξ ξ 'San Jose', ξ ξ ξ // city

ξ ξ 'California', ξ ξ // state or province

ξ ξ 'USA' ξ ξ ξ ξ ξ ξ // country

ξ ]);



ξ ξ// add item might be called for every item in the shopping cart

ξ ξ// where your ecommerce engine loops through each item in the cart and

ξ ξ// prints out _addItem for each

ξ _gaq.push(['_addItem',

ξ ξ '1234', ξ ξ ξ ξ ξ // order ID - required

ξ ξ 'DD44', ξ ξ ξ ξ ξ // SKU/code - required

ξ ξ 'T-Shirt', ξ ξ ξ ξ// product name

ξ ξ 'Green Medium', ξ // category or variation

ξ ξ '11.99', ξ ξ ξ ξ ξ// unit price - required

ξ ξ '1' ξ ξ ξ ξ ξ ξ ξ // quantity - required

ξ ]);

ξ _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers



ξ (function() {

ξ ξ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;

ξ ξ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';

ξ ξ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);

ξ })();



</script>

Creating custom 404 page

Everyone at some point has been browsing trough google or their favorite search engine and clicked on a link just to go into a white page with the words ???404 Error??? up on top. After this the only thing you have is to hit the ???Back??? button on your browser. As a user, this means that you go backand try another link. As a developer do, it means that you lost a potential clients, and that you have a glitch in ξyour application that you are not aware of.

You can set upt a custom 404 page using your apache .htaccess file. Here is how to do this:

  1. Access your server via FTP
  2. Make sure that you can see hidden files
  3. Locate for .htaccess
  4. If .htaccess does not exist go ahead and create it
  5. Open the file
  6. Type: ErrorDocument 404 /404.php
  7. Save the file
  8. Now you can go and edit this file so that you can have a custom error page.

That is all that you have to do in order to set up your server to have a custom 404 page. Use your imagination on this one, for examle you can have a search function or related pages to what the user was looking for. You can also have this page email you so that you become aware of the situation.

Hope this helps, any questions or concerns can be submitted below.

Basic AJAX connection using the POST method to retrieve content

Hello guys,

I have been working on a project for school which used AJAX and I just wanted you guys to have this code for reference. This code basically makes a call to a PHP script which gets Zip Code information (city and state) and then adds them into your web page. I used a span tag with id of ???zipinfo??? to act as a holder for the content that was going to be retrieved. Hopefully this helps some of you in your projects.

//Get Zip Code Information

function zipInfo(zipcode) {

fieldValue = ???connection=zipInfo&zip=???+zipcode;

var url=???includes/management.php???;

httpRequest(???POST???, url, true, fieldValue, function(result){

document.getElementById(???zipInfo???).innerHTML = result;

});

}

//AJAX Request

function httpRequest(reqType, url, asynch, fieldValue, callback) {

request = new XMLHttpRequest();

request.open(reqType,url,asynch);

request.setRequestHeader(???Content-type???, ???application/x-www-form-urlencoded???);

request.setRequestHeader(???Content-length???, fieldValue.length);

request.setRequestHeader(???Connection???, ???close???);

request.send(fieldValue);

request.onreadystatechange = function() {//Call a function when the state changes.

if(request.readyState == 4 && request.status == 200) {

callback(request.responseText);

}

}

}

Creating a Sample HTML5 Structure

 

TML5 is the thing that developers are starting to take a look more and more. More and more browsers are getting compatible with it and with the iPhone choosing this as it???s main multimedia language I have no doubt that this will be demanded in great quantities. In this post I will explain how to create a sample HTML5 structure for your web site.

<!DOCTYPE HTML>

<html lang="en">

<head>

<meta charset=utf-8>

<title>Sample HTML5 Structure</title>

<style>

header, nav, article, footer, address, section {

ξdisplay: block;

}

#container {

ξwidth:900px;

ξmargin:auto;

ξbackground-color:white;

}

header {

ξbackground-color:#666;

}

nav li {

ξdisplay:inline;

ξpadding-right:1em;

}

nav a {

ξcolor:white;

ξtext-decoration:none;ξ

}

nav a:hover {

ξtext-decoration:overline;ξ

}

h1, h2 {

ξmargin:0px;

ξfont-size:1.5em;

}

h2 {

ξfont-size:1em;

}

footer {

ξbackground-color:#999;

ξtext-align:center;

}

</style>

<script>

document.createElement("article");ξ

document.createElement("footer");ξ

document.createElement("header");ξ

document.createElement("hgroup");ξ

document.createElement("nav");ξ

</script>

</head>

<body>

<div id="container">

ξξξ <header>

ξξξ ξ<h1>Sample HTML5 Structure</h1>

ξξξξξξξ <nav>

ξξξξξξξξξξξ <ul>

ξξξξξξξξξξξξξξξ <li><a href="#">Home</a></li>

ξξξξξξξξξξξξξξξ <li><a href="#">About</a></li>

ξξξξξξξξξξξ </ul>

ξξξξξξξ </nav>

ξξξ </header>

ξξξ <section>

ξξξ ξ<hgroup>

ξξξξξξξ ξ<h1>Main Section</h1>

ξξξξξξξξξξξ <h2>This is a sample HTML5 Page</h2>

ξξξξξξξ </hgroup>

ξξξ ξ<article>

ξξξξξξξ ξ<p>This is the content for the first article</p>

ξξξξξξξ </article>

ξξξξξξξ <article>

ξξξξξξξ ξ<p>This is the content for the second article</p>

ξξξξξξξ </article>

ξξξ </section>

ξξξ <footer>

ξξξ ξ<p>This is the Footer</p>

ξξξ </footer>

</div>

</body>

</html>

As you can see the syntax is very similar, the start tags changed somewhat, but it makes it more convinient for the coder. Alsoas you can see now instead of making separate divs to stylize the header and footer, now HTML5 gives you a specified tag for each of them. The <nav> tag is the where your main site navigation will be at. You can also see the <section> tag, this will define the differents parts of your page, for example articles, blogroll, etc.ξ The <hgroup> tag is used to group various content heading, for example when you have an Article title and a Subtitle.

The JavaScript part of the code will create the tags so that older browsers and IE will accept them. This step is very important, if you do go ahead and skip it then older browsers will have trouble understanding your ode and the results will vary a lot.

Please leave any comments and/or suggestions below,

Gilberto Cortez

Image Resizing with PHP

Hello guys,

Today I will post a image resizing script, this will assist you in all of your sites specially ecommerce ones in which you need to display your products with different sizes. The script is self explanatory, but please send me a message or a comment if you need further assistance with it.

//Image Target

$pic = ???images/???.$_GET[‘pic’];

//Set Max Sizes

$max_height = 48;

$max_width = 48;

//Get Image Size

$size= getimagesize($pic);

//Set Ratios

$width_ratioξ = ($size[0] / $max_width);

$height_ratio = ($size[1] / $max_height);

if($width_ratio >=$height_ratio)

{

$ratio = $width_ratio;

}

else

{

$ratio = $height_ratio;

}

//Set new size

$new_widthξξξ = ($size[0] / $ratio);

$new_heightξξ = ($size[1] / $ratio);

//Set header

header(???Content-Type: image/jpeg???);

//Create Image

$src_img = imagecreatefromjpeg($pic);

$thumb = imagecreatetruecolor($new_width,$new_height);

imagecopyresampled($thumb, $src_img, 0,0,0,0,$new_width,$new_height,$size[0],$size[1]);

imagejpeg($thumb);

imagedestroy($src_img);

imagedestroy($thumb);

All you need to do now is to point the src element of your image tag to this script, and set the file you desire using the get method. Ex: img.php?pic=image.jpg

Please contact me with any doubts,

GilbertoξCortez

Interactive Web Development for ???The Cloud???

Lesson 2: Pre-Production Process and Market and Keyword Analysis

This is the second part of a series of search engine optimization lessons. On this lesson I will start to explain you what I call the “Pre-Production” process of your campaign. At the start of each campaign one must do a market and keyword analysis research. Market Research is when one researches and evaluates the current online competition for that specific client. By doing this you will be finding out who your actual competition is and what they are doing to stay on top of things. You can find your competition by using different methods, one of them is by doing a search on the keywords that you think your client will rank for, and you will notice that some websites will start to looking familiar after a while. Write them down in a document.

Once you complete your list, go back and start analyzing each of this websites. I usually note the 10 most relevant competitors that I will be going against to in the Search Engine Results Page or commonly known as the SERP. Take a close look at these sites as these competitors are doing something right because they are currently ranking for what you want. The most important things to look at are what they are using in their Meta Tags, most importantly the content of the Title Tag and the Keyword Meta Tag. Start writing in a document a list of all of the keywords that you think is important; they will help you when you start doing your own keyword research. Each client will be a different type of business so try to learn as much as you can about the business when you are doing this. It will help you throughout the project and when conversing with the client as you will be more knowledgeable. You can also find out how hard or easy it will be for you to rank for the specified keyword. If your competitors all have page rank of 6 and 7 then it will be a pretty though road to beat, nothing is impossible tough.Once you complete a full evaluation of competitors, you will continue into starting your keyword analysis. A keyword analysis needs to be done in order to find a list of appropriate target keywords. By appropriate I mean keywords that you will be able to effectively rank for and bring traffic to their web site and increase their ROI (Return on Investment). There are many tools out there that can help you do this, there is one that I have found the most useful. The Google Ad Words Keyword Tool, which is free of cost to use. In order to take advantage of all of the features that this tool can offer you should create a Google account and log in each time before you use the keyword tool. This tool will provide you with all the relevant information for your project. On the top box you will input ideas of keyword that you have might thought that you wanted to rank for. The keyword tool will return you with up to 800 related keywords, find the ones that you think are the most important to your site and store them in an Excel spreadsheet, save the keyword and the traffic – for this I use Global Monthly Searches. Make sure that you do not repeat them, and start sorting them out by similarity. Once you think you had enough go back and try organizing them once more. At the end sort each of the categories by traffic. This will now be the keyword which you will base your campaign on.Click Here to Download my Sample Spreadsheet to save the information you have found on your research.While doing your keyword researches you should know this. Don???t try to rank for a keyword that you are never going to get. Example: Don???t go and try to rank for Music Videos when trying to rank an upcoming artist debut video, try ranking for something more relevant like ???Upcoming Pop Artist {Artist Name} Music Video??? which will bring you better result. But also don???t go and only try to rank for keywords that does not have any traffic to it as it will not bring you a lot of traffic. Also, try using a thesaurus or a dictionary to find others way that people could write your term as. This might bring you additional traffic that not a lot of people are going after but that a lot of people might be searching for.

In my next lesson I will teach you how to take these keywords and start using them to optimize your web pages. Hope that you liked this lesson and please if you did share it below via Twitter or Facebook. And once again if you have any questions or comments please write them on the form below.

 

Lesson 4: Internal and External Linking

This is the fourth part of a series of [kastooltip msg=”search engine optimization” tooltip=”The process of improving the visibility of a website or a web page in search engines via the natural search results”] lessons. On this lesson I will be explaining you the methods to do internal and external link campaigns. Linking is probably the most important factor at this time on ranking for a specified term. There is internal linking which refers to the linking within your domain. There is external linking which refers to links that are pointed into your site from external domains. During this lesson I will be referring to anchor text constantly, by this I refer to the text that is within your anchor link html tags.

 

Example: (Anchor Text is Highlighted)

<a href=”linking-example.php” title=”Linking Examples”>View Linking Examples</a>

As you can see there are two more factors to this anchor tag that are in it. The href is the URL where you are pointing the link to. This URL needs to contain a keyword that you are trying to go for. If your links are going to be directed to a dynamic script where you will have multiple variables in them, try using URL Rewrites to make SEO friendly URL???s. The title is basically the title of your link, again try to use a keyword in here when writing these tags.

Internal linking is taken into consideration by Google in different ways. First it will take the keywords that are used throughout to link your site together. Some example of this links include your main navigation, footer navigation, call to actions, etc.

Example:

To link to an online marketing company about page, the tag will look something like:

<a href=”about-online-marketing-company.php” title=”About Online Marketing Company Interactive Utopia”>About Online Marketing Company Interactive Utopia</a>

As you can see we use our keywords to create our anchor tags for our site. Try to avoid using images or JavaScript for your navigation as this is not read by spiders. The best method to create your site navigation is UL lists and CSS to make it look good. Also if it???s an important page, remember to link it from a main navigation and don’t have it hidden. I will go a little bit further on this subject on another lesson.

External linking is probably the most important ranking factor at the moment. This is because the search engines believe that basically the more people link to you the better your content is suppose to be as it satisfies all of this different people. The first thing to remember is to try to get all the links to your site to have keywords that you want to rank for in the anchor text. There are different methods that you can use to generate external links to your site.

A good way to do this is to write and distribute press releases. You can create these ones for different events that you will be sponsoring, or for products that you will be launching, etc. On this press releases include your keyword rich links and use a press release distributor to publish your release. If your release is relevant to the public it will be caught up by different news sites, and when they publish them some of them will include your links on them.

Another good method is to have a blog in your site and continuously write on it. This will create more content on your site for users to read and if they like it they will share it with their friends, or on their web sites. Try to have a way to share your content easily. If you are using a CMS like WordPress, Drupal, or Joomla! They all have a plug in that can do this for you.

You can also have a link exchange. This is when you know the owner of another site and he agrees to link to your site if you link to his. This will help you but the algorithm gives less authority to these types of links. The one with the most are the one-way links or links that link to you but you do not link back to them. There are a lot of different creative ways

My next lesson will be about setting up analytics and goals on your site to track your progress. This is very important as you need to keep track if your theories are working. If you see that traffic is going up or down. Or if you see traffic but no conversions. This is all problems that you will only be able to resolve trough looking at your site analytics. Hope that you enjoyed this lesson, please if you did share it below via Twitter or Facebook. If you have any questions or comments please write them on the form below.

 

Lesson 3: On Page Optimization for SEO

This is the third part of a series of search engine optimization lessons. On this lesson I will be explaining you the methods to do the actual on page optimization. You will take what you have learned from past lessons and use it to create the proper tags for your pages. When Google analyses your cached content in his algorithm it gives special consideration to certain tags on your page. When I speak of on page optimization I refer to the optimization of these tags to increase your possibility to rank for your target keywords.

The most important is the Title Meta Tag, which is located at the header of your page. This tag along can count up to 20% of the total value of your page on the algorithm. When writing keep this tag under 70 characters long. Also, the algorithm will give more value to the keywords that are more on the beginning of your tag. Keep your most important keywords at the start; here are different ways to create Meta tags:

  • {keyword 1} | {keyword 2} | {site name}
  • {keyword} – {category} | {site name}

Another important one is the Description Meta Tag. This tag counts in a small percentage of the actual value of your page on your algorithm, but what you state on this tag is what it will be shown as a description in the SERP???s. If you have a properly written description tag for your page you will increase the chances of having click-troughs. Write this tag using keywords on your list.

Some other tags to consider are the headers. These tags include <h1>, <h2> and <h3>. Use this tags to properly organize your web pages, it will also help you keep the style consistent throughout the site. Another tag that will give more power to a keyword is by using the <strong> tag. Now days the algorithm is also taking a look at how you are styling your site. So for example if you use CSS to make a <span> bigger and bolder, then it will take this in consideration and give more value to the words that are inside of these tags.

And then comes the page primary content. This is a very important part for ranking for the keywords that you like. Always keep the content related to the theme of the site and use your keywords in it. Use multiple synonyms or others ways of writing it trough your content, this will help you rank for alternate searches and bring in more traffic. One thing to watch is keyword spamming, by this I mean don???t write the same keyword 100 times on a 300 word page. This will mark the page with a red flag and it might hurt your rankings.

Always remember, if you combine all of these factors together with your keywords in a balances way it will make your job way easier. Some people say that links will help you rank, but if you do not have the proper on page optimization it will be really hard to rank for your goal.

In the next lesson I will be discussing internal and external link building. This is a very important process if you want to rank for hard keywords. Remember SEO is a process, so if you build up your site with all of the different pieces properly configured you will be very successfully to reach your goal. Hope that you enjoyed this lesson, please if you did share it below via Twitter or Facebook. If you have any questions or comments please write them on the form below.

References:

Keyword Targeting & On-Page Optimization | SEOmoz

Transfer a Large Database using MySQL Dump and a SHH Client

Have you needed to transfer a large database? One of an eCommerce Cart or of a big blog? phpMyAdmin only allow’s imports of databases of 2 mbs, if you fix the php.ini file you can get maybe 10 or 12 max on most servers. In order to move this you will need to do it through shell access. Here is instructions on how to do this:

  1. Contact your service provider and tell them to allow shell access in your account.
  2. Download a SHH client like puTTY
  3. Open the application, enter your domain and the port. (I have usually encounter them to be 22 or 2222)
  4. Enter your username and password. These are usually the same as your FTP credentials.
  5. To export or dump the MySQL database you will be using a tool calles MySQL Dump, to do this you will type:
    1. mysqldump -u [username] -p[password] [dbname] | gzip > [location/name].sql.gzip
    2. the items in [ ] need to replaced and the brackets removed. Also please note there is no space between -p and your password
    3. This will create what is called a dump file of your database which will be gzipped for easier development.
  6. Now you need to get the file that was created and upload it to your new site via an SFTP or FTP client.
  7. After this enable shell access on your new server or location and access it
  8. First we need to decompress the .gzip file, to do this type:
  9. gzip -d [location/file].sql.gzip
  10. After this is completed the gzip file will dissapear and you will only have the sql file needed.
  11. Now all you need to do is import the file into your database, to do this type:
    1. mysql -u[username] -p[password] [dbname] < [location/file].sql
  12. Your import and transfer of your MySQL database is now complete.

————

Do you need any work performed on your database or on your web application? You can contact me at (619) 800-2678 or using the Quote Request form.

My attempt to create the perfect Social Media Campaign

This is the first of a series of blog post that I will be writing about my attempt to create the perfect Social Media Campaign. I will try to evaluate all of the factors that need to be evaluated and integrated into this campaign in order to beξsuccessful. Here is some information about the company that I will use as sample:

  • Name: GC Termite Control
  • Industry: Termite & WDO Control
  • Website: GCTermiteControl.com
  • About It: Small family owned business that serves the greater San Diego county area. The company specializes in serving the Real Estate industry.

Firstly I have to decide which social media networks we will be involved in. Keeping in mind that our target audience are professionals that work in the real estate industry which include Realtors, Escrow Officers, Loan Officers, Listing Managers, Branch Managers and other. After careful consideration and research here are the networks that I have selected to include in this campaign.

  • Facebook
  • LinkedIn
  • Twitter
  • Google+
  • Reddit

The main purpose of this campaign will be primarily to increase the company visibility and trust. This will be created by using a different amount of methods. The first method that I will try is to generate more company visibility by the creation of a Facebook Ad.

  • Tips
  • How To’s
  • Content Strategy