PayPal Hacks. 100 Industrial-Strength Tips and Tools Free Open Book

PayPal Hacks. 100 Industrial-Strength Tips and Tools

Previous Section  < Day Day Up >  Next Section

Hack 53 Remember Your Customers

figs/moderate.gif figs/hack53.gif

Track your site visitors, regardless of whether they made a purchase with PayPal.

As your eCommerce site becomes more advanced, you might want to begin tracking visitors as they move through your site. For example, you could create a membership system, encouraging users to register and then log in during each subsequent visit. Once acknowledged, your users might have access to special insider deals or premium content. Or, you could address your customers by name on your site's pages.

However, there's a downside. Designing, building, and maintaining a membership database for customers can be a lot of work, and some customers might balk at being asked for a username and password each time they visit. Using the techniques in this hack, you can identify your users by name and offer buyers-only content in minutes—no login required.

5.10.1 Tracking Buyers with Cookies

A popular way to remember your visitors is by using cookies. Cookies are small chunks of information that a user's browser remembers on behalf of your web site. They are handed back to your web site (if it asks) on a subsequent visit. By setting, then reading back, personal information for a visitor, your web site can remember your customers.

This hack sets a cookie when your buyer has returned to your site after making a payment to you with PayPal. Your site will look for this information whenever someone visits and, if found, use it to personalize the site by using the buyer's name and granting access to customer-only content.

You can implement this hack with any web scripting technology; the example code uses ASP with VBScript.

5.10.2 The Return Page

The return page is a page on your site that is activated after a payment has been made, when the buyer clicks the "Click here to continue" link on the You Made A Payment page. Set the return variable in your Buy Now button to the URL you want to use.

Use the return page to create cookies that record the user's name and the fact that the user is a buyer. You should also set the cookies' expiration times; if you don't set the cookies to expire in a set amount of time (such as about an hour, as in the following code), the settings will be lost at the end of the session (such as when your customer closes the browser).

Here's a simple ASP implementation of this:

<% 

'Set cookie expiration

'If this is a completed payment, set "paid" to "yes"

If Request.Form("payment_status") = "Completed" Then

  Response.Cookies("paid") = "Yes"

  'Set the expiration time of the cookie

  Response.Cookies("paid").Expires = Now( ) + 0.042 'About 1 hour

End

Response.Cookies("user") = Request.Form("first_name")

'Set the expiration time of the cookie

Response.Cookies("user").Expires = Now( ) + 0.042 'About 1 hour

%>

The user is identified by the first name provided by PayPal via the first_name variable. The paid cookie remembers that this user is a paying customer; user stores the buyer's name.

In addition to the cookie-handling code in this example, you'll want to have links to other portions of your site, such as your home page.

5.10.3 Cookies at Work

You can use the cookies you created on the other pages of your site. For example, you can greet your customer by name:

Welcome<br><%= Request.Cookies("user")%><br>

Or you can reward your loyal customers with inside information:

<% 

If Request.Cookies("paid") = "Yes" Then

'They have paid, show secret text

%>

We'll be having a <b>big sale</b> on all our exclusive monkey toys this

Thursday! (Preferred customers only.)

<%

End If 

%>

This code shows the secret text only to people who have completed a purchase using PayPal.

5.10.4 Hacking the Hack

PayPal provides more information to your return page than just the payment status and the buyer's name. For example, you can also get the name of the item purchased. Try this addition to your return page to record the item name:

<% 

'Set cookie expiration

'If this is a completed payment, set "paid" to "yes"

If Request.Form("payment_status") = "Completed" Then

  Response.Cookies("paid") = "Yes"

  'Set the expiration time of the cookie

  Response.Cookies("paid").Expires = Now( ) + 0.042 'About 1 hour

  Response.Cookies("item_name") = Request.Form("item_name")

  Response.Cookies("item_name").Expires = Now( ) + 0.042 'About 1 hour

End

Response.Cookies("user") = Request.Form("first_name")

'Set the expiration time of the cookie

Response.Cookies("user").Expires = Now( ) + 0.042 'About 1 hour

%>

Then, use the item name in your content pages:

Welcome<br><%= Request.Cookies("user")%><br>

<% 

If Request.Cookies("paid") = "Yes" Then

%>

Thank you for your recent purchase of 

<%= Request.Cookies("item_name")%>.

<%

End If 

%>

You will need to modify this code for shopping cart applications, because there will likely be more than one item name.


Also, remembering your customer for an hour might not be as long as you would like. Try setting the value to a year:

Response.Cookies("paid").Expires = Now( ) + 365 'About a year

5.10.5 See Also

The "HTML and Hyperlink Variables" section in the PayPal Buy Now Buttons Manual offers important information about using the return and rm parameters.

    Previous Section  < Day Day Up >  Next Section
    Index: [SYMBOL][A][B][C][D][E][F][G][H][I][J][L][M][N][O][P][Q][R][S][T][U][V][W][X][Y]


         Main Menu
    PayPal Hacks
    Table of Contents
    Copyright
    Credits
    Preface
    Chapter 1. Account Management
    Chapter 2. Making Payments
    Chapter 3. Selling with PayPal
    Chapter 4. Payment Buttons
    Chapter 5. Storefronts and Shopping Carts
    Introduction: Hacks #45-50
    Hack 45 Hack Shopping Cart Buttons
    Hack 46 Create Shopping Cart Links
    Hack 47 Specify the Size of the Shopping Cart Window
    Hack 48 Deal with Design and Layout Issues
    Hack 49 Put Both Cart Buttons in One Form
    Hack 50 Integrate a Third-Party Shopping Cart with PayPal
    Hack 51 Customize Checkout Pages
    Hack 52 Display the Merchant Transaction ID on Your Return Page
    Hack 53 Remember Your Customers
    Hack 54 Create a Dynamic Storefront
    Hack 55 Add Dynamic Storefront Details
    Hack 56 Insert Dynamic Images
    Hack 57 Build an Order-Tracking Page
    Hack 58 Offer Discount Coupons
    Hack 59 Increase Search Engine Exposure
    Hack 60 Sell Digital Goods with PayLoadz
    Chapter 6. Managing Subscriptions
    Chapter 7. IPN and PDT
    Chapter 8. The PayPal Web Services API
    Colophon
    Index


    More Books
    PHP Hacks
    Processing Xml With Java - A Guide To Sax, Dom, Jdom, Jaxp, And Trax
    The Koran (Holy Qur'an)
    Macromedia Flash 8 Bible
    Search Engine Optimization for Dummies
    YouTube Traffic
    PHP 5 for Dummies
    Harry Potter and The Chamber of Secrets
    Harry Potter and the Sorcerer's Stone
    The Pilgrim's Progress
    Wireless Hacks
    Flash Hacks. 100 Industrial-Strength Tips & Tools
    PayPal Hacks. 100 Industrial-Strength Tips and Tools
    Amazon Hacks
    Pdf Hacks
    The Da Vinci Code
    Google Hacks
    The Holy Bible
    Windows XP For Dummies
    Harry Potter and the Half-Blood Prince
    Seo Book
    Upgrading and Repairing Networks
    Macromedia Dreamweaver 8 UNLEASHED
    Windows XP Annoyances
    Windows XP Hacks
    Microsoft Windows XP Power Toolkit
    Teach Yourself MS Office In 24Hours
    iPod & iTunes Missing Manual
    PC Hacks 100 Industrial-Strength Tips and Tools
    PC Overclocking, Optimization, and Tuning - 2th Edition
    PC Hardware In A Nutshell 3rd Edition
    PC Hardware in a Nutshell, 2nd Edition
    Upgrading and Repairing PCs
    Google for Dummies
    MySQL Cookbook
    Teach Yourself Macromedia Flash 8 In 24 Hours
    PHP CookBook
    Sams Teach Yourself JavaScript in 24 Hours
    PHP5 Manual
    Free Games Paper Airplanes
    500 Juegos Gratis 500 Giochi Gratis 500 Jeux Gratuits 500 Jogos Gratis 500 Kostenlose Spiele