Atlantic Business Technologies, Inc.

Category: Managed Services

  • Dynamic Body ID and Class properties on ASP.NET Master Pages

    Master pages are a great feature of ASP.NET. However, they do have some drawbacks, one being they do not easily offer the flexibility of dynamic body ids and classes that our design team here needs.

    Luckily a solution exists, and best of all it isn’t all that difficult to implement. The solution is built around the idea that child pages can access their master page, as well as any publicly exposed properties on the master. For example, in the Page_Load method of a child page, you can write:

    MyMasterPage masterPage = Master as MyMasterPage; masterPage.Property = “property value”;

    This is not ideal though, because we are now committed to never changing our child’s master page; if we do, it will break our build. The correct implementation of this concept is to create an interface that all of our master pages will implement, then use that in our child pages’ Page_Load method:

    IMasterPage masterPage = Master as IMasterPage; masterPage.Property = “property value”;

    We can still set our property this way, only now we can later change what master page we use, as long as the new one still implements the same interface. Good stuff. So good, that it puts us most of the way there towards dynamic body ids and classes.

    To get these, we need a couple of properties on our interface:

    public interface IMasterPage { String BodyId { get; set; } String BodyClass { get; set; } }

    Then, in the code-behind file for our actual master page:

    public partial class MasterPagesDefault : MasterPage, IMasterPage { private string _bodyId; private string _bodyClass; public string BodyId { get { return _bodyId; } set { _bodyId = value; } } public string BodyClass { get { return _bodyClass; } set { _bodyClass = value;} } }

    Finally, in the master page’s body tag:

    <body id=”<%= BodyId %>” class=”<%= BodyClass %>”>

    Now, to set these dynamically, use the child page’s Page_Load method just like before:

    IMasterPage masterPage = Master as IMasterPage; if (masterPage != null) { masterPage.BodyId = “index”; masterPage.BodyClass = “index two-col”; }

    By using publicly accessible properties, we give child pages the ability to set values on their master page. With this, it is easy to create dynamic body classes and ids in .NET.

  • Key Performance Indicators Every Website Should Track

    No matter what type of website you create, you should always monitor your website statistics. You can gain a wealth of knowledge about your site traffic, just by looking at a few key performance indicators (KPIs). Every sites KPIs will be a little bit different and certain data will be more important than others, however there is data that is worth monitoring all of the time.

    Bounce Rate

    Your bounce rate is simply when a visitor enters your site and does not go to any other page on your site. This data can help you identify certain pages that need improvement. For example, if you have 10 service pages on your site and 3 out of the 10 have an extremely high bounce rate compared to the rest, it may mean that you need to add/change content, replace images, or add an offer/call to action. If your bounce rate is not design related, it may be that you are driving the wrong type of traffic to the site. Organically, if you are optimizing your site for the wrong keywords/phrases you could be driving irrelevant traffic to your site. On the paid side of things, if you are bidding on the wrong keywords or that the keywords are too broad you may have to bid on more targeted keywords.

    clock_no_border

    Time On Site

    The time on site indicator is very closely related to bounce rate. It is one of the best ways to see how engaged your visitors are on your site. If you notice that visitors are leaving within 30 seconds, you may not have content that is not compelling enough for a user to stay. Usually if your time on site is low, you will notice a higher bounce rate. Like bounce rate, if you drive the wrong type of traffic to the site you may have a low bounce rate.

    Unique Visitors

    Depending on the type of site you have, you may want to know how many new visitors you have compared to returning visitors. If you are managing a content-based site like a blog, forum, or wiki, you may want to take notice of visitors who return to your site. However, if you are a business trying to gain market share in your industry you may want to see what percentage of new users are visiting the site.

    Top Keywords

    It is always important to see what top keywords people are using to find your site. Your keyword list can help you see what keywords you are organically showing up for in the search results. Along with top keywords, pay close attention to each keyword as it correlates with time on site. You will notice that certain keywords/phrases will bring you higher time on site, lower bounce rates, and higher conversion rates.

    Top Content

    Track New Account Openings

    Extremely important for e-commerce sites, monitoring your most visited pages can help generate more revenue. Analyzing to see what products people are looking for can help you determine which products to market and promote more. For blogs and content focused sites, seeing which articles or blog posts are most popular can help you figure out which content you should highlight on your site or re-purpose on other content sharing sites.

    Goal Conversions

    Ultimately your site conversions are what generates leads and sales. When monitoring conversion data you want to look at it from a few angles. From one side, you want to see where your conversions are coming from. Are they coming from Google? A site you are marketing on? Paid search? An email marketing campaign? From another side, you want to see what keywords people used to convert. You may see trends in certain keywords that convert better than others. Another angle to look at is geo-location. Are more people converting within your city? State? Country?

  • Caching Twitter Statistics Locally

    twitterSocial networking tools seem to have become one  of the  more popular Internet technologies today.  Out of the many available, Twitter is ahead of them all when it comes to popularity and micro-blogging. While browsing the Internet you may run across a site that has taken advantage of Twitter’s portability by integrating their Twitter feed within the site.

    There are many different ways to retrieve Twitter user information, one of which is using the Twitter API. The Twitter API provides a variety of functions that can be used to retrieve a user’s account data.  On one hand it is very beneficial to use these API functions by reducing in-house programming, but on the other hand making multiple calls to an API from a site that has a large volume of traffic can cause issues like affecting download times and generating errors.

    In our development group, when we need to implement a Twitter feed and not affect performance of the site we prefer to cache the information in a database.  We do this by writing a script that runs as a scheduled service from the database.  This script makes a call to one of the common Twitter API functions to retrieve the user’s timeline.  In this post I will be specifically focusing on the .NET framework.

    ABT_Twitter t2 = new ABT_Twitter();
    
    string timelineAsXml = t2.GetUserTimeline("username", "userpass", OutputFormatType)
    

    Now that we have the data we need from Twitter we can begin picking apart the data to store into our database. In this case we chose XML as the OutputFormatType so first we need to create a XmlDocument to store the local string variable.

    XmlDocument xmlDoc = new XmlDocument();
    
    doc.LoadXml(timelineAsXml);
    

    The next step is to create a simple DataTable that will store each of the desired values to be retrieved from the Twitter API, then we need to add the columns for the values we choose to cache.

    DataTable tweetDataTable = new DataTable();
    
    tweetDataTable.Columns.Add("value1");
    
    tweetDataTable.Columns.Add("value2");
    

    The next thing to do is to loop through each XmlNode in the XmlDocument we instantiated earlier for each node in a certain xpath.  Inside this loop we are going to create a new DataRow and set the values of the columns we added to the tweetDataTable earlier to the nodes we are trying to retrieve.  Once all of the values of the columns in the DataRow have been set we will need to add this new row to the tweetDataTable we created.

    foreach (XmlNode node in xmlDoc.SelectNodes("xpath")
    
    {
    
    DataRow tweetDataRow = tweetDataTable.NewRow();
    
    tweetDataRow["value1"] = (node["desiredNode1"].InnnerText);
    
    tweetDataRow["value2"] = (node["desiredNode2"].InnerText);
    
    tweetDataTable.Rows.Add(dr);
    
    }
    

    Now we have retrieved the information we need from the Twitter API and placed it into a DataTable. Also, we will perform an if statement to make sure that our DataTable has information in it to keep our script from performing unnecessary actions.  We will need to truncate the table that we are storing our Twitter information in to eliminate the possibility of redundant data.  After the table has been truncated our script will now loop through each row in the tweetDataTable we populated earlier and insert data associated with each “tweet.”

    if (tweetDataTable.Rows.Count > 0)
    
    {
    
    SqlCommand truncateCommand = new SqlCommand("truncateStoredProcedureName", connectionString);
    
    truncateCommand.CommandType = CommandType.StoredProcedure;
    
    truncateCommand.ExecuteNonQuery;
    
    for (int i = 0; i < tweetDataTable.Rows.Count; i++)
    
    {
    
    SqlCommand insertCommand = new SqlCommand("insertStoredProcedureName", connectionString);
    
    cmd.CommandType = CommandType.StoredProcedure;
    
    cmd.Parameters.Add(new SqlParameter("@parameter1", tweetDataTable.Rows[i]["value1"]));
    
    cmd.Parameters.Add(new SqlParameter("@parameter2", tweetDataTable.Rows[i]["value2"]));
    
    cmd.ExecuteNonQuery();
    
    }
    
    }
    

    And voilà! Now all of the information has been retrieved from the Twitter API and cached into a local database.  The idea behind using this method to retrieve the user information is to only call the script on a scheduled service so the service is not called every time the page is loaded.  Now that the data is stored locally it takes a simple database call to retrieve the information.

  • .NET Online Payment Gateways: A Factory Pattern Model

    One thing that any good development company should do is strive to create reusable code.  Thinking back to projects I’ve worked on in my first year here, it occurred to me that quite a few of them have involved some form of online payment processing.  However, each client has used a different payment processor that has required custom programming.  I began thinking how nice it would be to submit a generic payment object to a gateway with large disregard to what particular vendor the payment is being submitted to.   Early on in developing this, it occurred to me that a factory pattern would be the way to go; essentially what I want is a “factory” that will figure out what type of online payment gateway I need and construct that for me.

    To start things, I made a simple payment .NET gateway interface to make sure my gateway objects will do the one thing I need them to:


    public interface IPaymentGateway
    {
    string SubmitPayment(Payment payment);
    }

    Essentially what I’m saying here is that no matter what type of gateway I’m using, I’ll need to submit a payment.

    Next, we have a simple factory pattern to return some type of gateway:

    public class PaymentGatewayFactory
    {
    public IPaymentGateway CreatePaymentGateway()
    {
    PaymentGatewayRepository paymentGatewayRepository = new PaymentGatewayRepository();
    string gatewayType = paymentGatewayRepository.GetGatewayType();

    switch(gatewayType)
    {
    case “Authnet”:
    return new Authnet();
    case “Paypal”:
    return new Paypal();
    case “Payflow”:
    return new PayflowPro();
    default:
    throw new NotSupportedException(“This payment gateway is not supported.”);
    }
    }
    }

    Here we have a call to a PaymentGatewayRepository class (not included), which will read a config file and return a string representing what type of payment gateway the client is using. Next, a simple switch is done that will return the appropriate payment gateway class (or a custom exception if the gateway is not yet supported). Each of the gateway classes implements the IPaymentGateway interface.

    The beauty of this is that once this project is built, submitting payments is a breeze. Just include the assembly in a project, reference it, and then follow these three easy steps:

    1. Add the necessary config keys.<!-- Gateway types | Possible Values: Authnet, Paypal, Payflow -->
      <add key="GatewayType" value="Authnet">
      <!– Authnet Keys –>
      <add key=”Anet_URL” value=”http://test.authorize.net/gateway/transact.dll”/>
      <add key=”payment_login_key” value=”123456789″/>
      <add key=”payment_tran_key” value=”987654321″/>
      <add key=”payment_auth_name” value=”Example”/>
    2. Build the payment object.Payment payment = new Payment();
      payment.BillingFirstName = "Jeremy";
      payment.BillingLastName = "Wiggins";
      etc…
    3. Submit the payment.IPaymentGateway gateway = new PaymentGatewayFactory().CreatePaymentGateway();
      gateway.SubmitPayment(payment);

    And that’s all there is to it. This will be a nice addition to a reusable component library. Once the logic has been implemented for a new payment gateway, it never has to be thought about again. Just add a few lines to a config file and submit payments in a couple of easy steps.

  • Guide to E-Commerce: Usability, Upsell, Cross-sell, & Conversion

    The Guide to E-Commerce is a complete resource that talks about ways to engage your website visitors, stimulate interest in your products, improve the checkout process, and engage in other marketing tactics that will help promote your products.

    Guide to E-Commerce: Part I

    • Product Categories
    • Search/Sort Functionality
    • Product Photos
    • Product Descriptions

    Guide to E-Commerce: Part II

    • Sell-ups
    • Cross-sells
    • Product Comparisons
    • Customer Reviews/Ratings

    Guide to E-Commerce: Part III

    • Checkout Process
    • Timely Offers/Incentives
    • Seasonal Product Offerings

    Guide to E-Commerce: Part IV

    • E-mail Marketing
    • Mobile Alerts
    • Gift Cards
    • Affiliate Programs
  • Guide to eCommerce: Usability, Upsell, Cross-sell, & Conversions – Part IV

    In part 4 of the Guide to E-Commerce we will look at other ways you can drum up business, other than search engine traffic.

    Why settle for just one way a customer can reach and purchase your products?  There are a number of ways you can increase sales and promote your products other than people finding your site on a search engine.

    E-mail Marketingtemplates_large

    Leveraging your current customer basis is essential for any e-commerce site.  A current customer has already purchased from you, understands your company/products, most likely had a positive experience, and are more likely to purchase from you again.

    There are a few ways you can go about implementing an e-mail marketing strategy.

    1. Gain Feedback: You do not necessarily want to sell, sell, sell.  If all you do is fill up a users inbox with nothing but product offerings, you can almost guarantee that that user will get annoyed and unsubscribe immediately.  Try sending out a customer satisfaction survey.  This can be a great way to learn what customers think about your site, company and how you conduct business.  On a broader scale, if you listen to what customers are saying and making improvements on your products and services based on their feedback, you can bet that sales will follow.
    2. Cross-sells: Once a customer has purchased, send out a email thanking them for their purchase and include some complimentary products that go with what they just bought.
    3. Specials/New Product Promotions: Holiday promotion emails are a big part of a online store’s strategy.  Send out a blast to your current customers notifying them about the upcoming specials, savings, and promotions.

    Mobile Alerts

    With mobile technology really starting to develop, mobile marketing is becoming a mainstream marketing tactic.  More and more people have smart phones or blackberry’s that come with unlimited text and data transfer.  Try setting up a mobile marketing campaign and text your customers with promotions, shipping status updates, or even customer polls. MobileStorm and Broadtexter are a few companies that allow you to setup mobile marketing campaigns.

    x17_header

    Gift Cardsgiftcard

    Especially around the holidays, gift cards are a simple gift for anyone.  Allow users to purchase gift cards through your site.  Give multiple delivery options such as printable gift cards, physical cards, or e-mailed directly to the person.

    Affiliate Programs

    Affiliate marketing is a huge business.  People can make a pretty good living off of selling other companies products. Create an affiliate program using Link Share or Commission Junction and allow other people to sign up for your program and sell your products.  It is like having your own salesforce promoting your products without the overhead!  Yes, they will receive a percentage of every product they sell, but a sale is a sale.  Just think about the lifetime value of a customer.

    affiliate-marketing-leads

    << Guide To E-Commerce Part III