You are here: Home > Tools > eCampaigning Tool > Documentation > Action Counter

How To Incorporate Action Counter On An External Site

Here are easy-to-apply instructions on how to incorporate number of actions taken into an external site without any programming, using the counter JavaScript? "client". Only basic webmaster (HTML) skills are needed.

Installation Instructions

The counter is installed into a web site simply by adding a few simple tags to the HTML page on which the counter is meant to appear.

  1. As a first step, a JavaScript? file is loaded by adding the following to the page - usually into the HEAD section of the HTML file:

    <script type="text/javascript" src="http://somesite/myCampaigningAction/counter.js"></script>
    
  2. Next, the page needs to have a HTML element whose id attribute has value "counter". For example:

    <span id="counter">###</span>
    

    This is where the counter will appear IF there are more actions taken than the minimum threshold configured in the campaign action: the contents of the <span> element (###) will be replaced with the counter number value.

  3. Finally, an additional small configuration is needed to display the news. The "showcounter()" JavaScript? function must be called upon loading of the page.

    If the BODY element of the page does not yet have an 'onload' attribute, such needs to be added to initiate the display of the news. Here's how it would look:

    <body onload="showcounter()">
    

    On some pages, an onload attribute may already exist. In such cases, the javascript code placed in the onload attribute needs to be customized so that it calls "showcounter()", in addition to whatever else the code does.

  4. Changing the appearance

    The appearance of the counter can easily be changed by simply styling the counter by applying CSS (Cascading Style Sheet) style to the tag whose id is "counter". An example CSS snippet is shown here:

    #counter {
      color: black;
    }
    

Technical explanation

When user requests the page with counter incorporated into it, a javascript file is requested from the server. The server embeds the counter in the JavaScript? file and sends it to the user browser. The onload event is triggered and the showcounter() function is called. The function then merely locates the element whose id is "counter" and assigns the number as its content.

Caveats

This solution only works with fairly modern browsers that have adequate JavaScript and basic DOM (Document Object Model) support.




subject:
  ( 1 subscriber )
Sponsor the eC Tool

Can't help with development? Help pay for someone who can.

Fast checkout through Google   Sponsor:
£
  

Make payments with PayPal - it's fast, free and secure.   Sponsor:
£
  
Sponsorship details >
Go Beyond Tools...

Tools are helpful. But to be great at eCampaigning you need more: strategy, tactics, skills, experience, analysis, etc..

FairSay's Training helps you at whatever level of experience you are.