Announcement

Collapse
No announcement yet.

Webgains Integration Tutorial

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Webgains Integration Tutorial

    Integrating with Webgains

    Many people would like to integrate their Actinic Installations with Affiliate Networks such as Webgains http://www.webgains.com; these networks are composed of a group of merchants and affiliates. Merchants join the network in order to have affiliates promote their products. Because of the structure of this network, merchants are able to promote their products throughout a broad spectrum, lowering their advertising costs. – these networks often require quite involved integration.

    Webgains require data feeds which Mole-End offer as part of their wonderful Marketing Feed plug-in http://www.mole-end.biz/acatalog/Froogle_Mash.html .

    Below is a step by step guide on how to integrate Webgains into Actinic. (Maybe others can provide step by step instructions for the other networks.)


    Webgains Tracking Code

    Integration is the process of setting up your system so that it sends Webgains system messages when users place orders at your site. This is achieved by adding a small amount of JavaScript to the order confirmation page of your web site. This code activates the request to Webgains system and allows them to decide if a commission is due to an affiliate for the current transaction.


    Basic setup

    The basic way to get your program up and running is to run in standard mode and not send Webgains details of items that make up the transaction. However, whilst the quickest in the short-term, this is not the recommended way to run your program; it will provide you with a lower quality of reporting and mean that you can’t set different commission levels for different products.


    Step One

    We need to build a order total variable that doesn’t include either shipping or tax (as you don’t want to pay commission on these) and to present it without formatting (i.e. 14000.67 rather than £14,000.67 or even worse £14,000/67). We also want to be able to get at the coupon code so that we can track offline coupons, as some affiliates use direct mail in the real world to advertise merchants sites.


    1. In the site folder find OrderScript.pl
    2. Right click and select Open With > Notepad
    3. Find -
    $::s_VariableTable{$::VARPREFIX.'ACTINICORDERTOTAL'} = $nTotal;
    4. Add this code on the following line.
    $::s_VariableTable{$::VARPREFIX.'NUMERICSUBTOTAL'} = (($nTotal-$nShipping)-$nTax1)/100;
    #get at the coupon code
    $::s_VariableTable{$::VARPREFIX.'AFILVOUCHERCODE'} = $::g_PaymentInfo{'COUPONCODE'};


    You code should now look like the following:

    Code:
    # send the total as an integer in the currency base unit
    # e.g. "512834"
    #
    $::s_VariableTable{$::VARPREFIX.'ACTINICORDERTOTAL'} = $nTotal;
    $::s_VariableTable{$::VARPREFIX.'NUMERICSUBTOTAL'} = (($nTotal-$nShipping)-$nTax1)/100;
    #get at the coupon code
    $::s_VariableTable{$::VARPREFIX.'AFILVOUCHERCODE'} = $::g_PaymentInfo{'COUPONCODE'};
        
    Step Two

    1. In Actinic Design View select “Reciept” from the “select page type” drop down
    2. In the “Layout Code”
    3. go to the bottom of the code just before </body>
    4. Paste the following just before </body>

    Code:
    <actinic:block if="%3cactinic%3avariable%20name%3d%22IsNotPreviewMode%22%20%2f%3e"> 
    <!-- <webgains tracking code> -->
    <script language="javascript" type="text/javascript">
    <!--
    var wgOrderReference = "<actinic:variable name="TheOrderNumber" selectable="false" />";
    var wgOrderValue = "NETQUOTEVAR:NUMERICSUBTOTAL";
    var wgEventID = standardcommissionid;
    var wgComment = "";
    var wgLang = "en_GB";
    var wgsLang = "javascript-client";
    var wgVersion = "1.2";
    var wgProgramID = yourprogramnumber;
    var wgSubDomain = "track";
    var wgCheckSum = "";
    var wgVoucherCode = "NETQUOTEVAR:AFILVOUCHERCODE";
    
     if(location.protocol.toLowerCase() == "https:") wgProtocol="https";
    else wgProtocol = "http";
    
    wgUri = wgProtocol + "://" + wgSubDomain + ".webgains.com/transaction.html" + "?wgver=" + wgVersion + "&wgprotocol=" + wgProtocol + "&wgsubdomain=" + wgSubDomain + "&wgslang=" + wgsLang + "&wglang=" + wgLang + "&wgprogramid=" + wgProgramID + "&wgeventid=" + wgEventID + "&wgvalue=" + wgOrderValue + "&wgchecksum=" + wgCheckSum + "&wgorderreference="  + wgOrderReference + "&wgcomment=" + escape(wgComment) + "&wglocation=" + escape(document.referrer);
    document.write('<sc'+'ript language="JavaScript"  type="text/javascript" src="'+wgUri+'"></sc'+'ript>');
    // -->
    </script>
    <noscript>
    <img src="http://track.webgains.com/transaction.html?wgver=1.2&wgprogramid=yourprogramnumber&wgrs=1&wgvalue=NETQUOTEVAR:NUMERICSUBTOTAL&wgeventid=standardcommissionid&wgorderreference=<actinic:variable name="TheOrderNumber" selectable="false" />" alt="" />
    </noscript>
    <!-- </webgains tracking code> -->
    </actinic:block>
    5. Change yourprogramnumber to the program number that Webgains have supplied you with. This can also be found on the Technical Setup of the Program Settings available from the left navigation under Program Setup in the left navigation of the merchant area of your Webgains account control panel.
    6. Change standardcommissionid to the standard commission id that Webgains have supplied you with. This is also available from the “Commission Types” Choice under “Program Setup” in the left navigation of the merchant area of your Webgains account control panel.
    Hit apply.

    If you are happy to only have one commission level and aren’t that worried about full reporting you can upload (I normally do a refresh but I’m not sure if this is necessary). However for the extra features read on.
    Wayne Theisinger

    The Web's just settling in. We got the tech, now let's put up something that matters.

    #2
    Full Reporting

    It is recommended to pass webgains the details of transactions so that you can check that you are paying the right commissions for the right types of goods and analyse sales & commissions by product or types of product.
    To do this, you can pass details of all the items as part of our confirmation code.
    eg, You can send Webgains the details of items in the following way:
    • Each item is separated by the pipe symbol (|)Each item can have a minimum of two properties and a maximum of four:-
    • Each item property should be stored as a string separated by two colons '::'
    eg, 498::54.99::Harry%20Potter%20dvd::hpdvd93876


    We will use these items to calculate commission due on those items. For unitemised amounts we will pay commission at your default rate; this way you can specify higher or lower rates for specific items without being forced to give details of ALL items.


    All of the above information is available within Actinic with the exception of Commission/EventID and to correct this we will create a user defined variable.


    Adding AffiliateCommissionID to the library


    1. Go to Design > Library click on the Variables tab – open the Product sub group by clicking on the plus next to the name. Right click the name “Product” and select “New Variable”.
    2. Type AffiliateCommissionID in the name field
    Type a description of your product groups in the description field – for example I’ve typed “Affiliate Commission Id: 1552 = Most Products: 1610 = Honda: 1611=Ride Ons and Hayter”

    Note: You can set the Commission Ids within your Webgains Control Panel by clicking on the Commission Types link in the left nav.

    Type a prompt for the Commission Id for example “Webgains Commission ID”
    Place of setting:

    · Site
    · Section
    · Product
    · Tab Name: Properties
    · Type: Text
    · Allow Empty: Unchecked
    · Allow “Use Parent”: Checked
    · All other checkboxes: Unchecked
    · Initial value: Use Parent
    · Top level value: your default Commission Id for example I’ve used “1552”


    Now Click Ok and close the library.

    Getting AffiliateCommissionID to display in the perl files

    To use a user variable on a Perl generated page you have to check the Upload option in the variables definition. That makes it available to the Perl Cart scripts.

    However being "available" doesn't mean you can use it. You then have to do significant customisation to ActinicOrder.pm and OrderScript.pl if you want this info displayed.

    On balance this struck me as much too complicated and instead I choose to employ a client side javascript solution adding an OnClick event to the “buy now button” that will store the Commission ID of a product into a cookie for later retrieval on the receipt page. (continued below…)
    Wayne Theisinger

    The Web's just settling in. We got the tech, now let's put up something that matters.

    Comment


      #3
      The JavaScript cookie functions

      I have written a small javascript library of cookie functions which I’ve attached as a zipped .js text file called affiliateScheme.js. Download this file and save it unzipped into your site folder.
      Including the cookie function file in the upload

      From the design menu select Additional Files hit add files and navigate to and select affiliateScheme.js from your site folder, press ok.
      Attached Files
      Wayne Theisinger

      The Web's just settling in. We got the tech, now let's put up something that matters.

      Comment


        #4
        Referencing the Affiliate JavaScript file from each page of your site

        In the design tab use the dropdown to navigate to Content Page. Copy and Paste the below code:
        Code:
        <script language="javascript" type="text/javascript" src="affiliateScheme.js"></script>
        Just below:
        Code:
         <script language="javascript" type="text/javascript" src="actiniccore.js"></script>
           <script language="javascript" type="text/javascript" src="actinicextras.js"></script>
        You will need to include a reference to the JavaScript file from all outer-layouts that use the Add to Cart Button layout. You can access the main of outer-layouts that are in use by using the dropdown in the design tab to navigate to “Content Page” and then using the Content Tree to navigate to pages that are using different templates – knowledge of your own site should tell you how many different templates are in use – In most sites you will probably find that you only actually need to make the change in one template.
        You will also need to insert the code into the outer layouts for the following selections in the dropdown menu (you may find that the change has already been made if the pages share the same outer layout):
        1. Shopping Cart
        2. Checkout 0
        3. Checkout 1
        4. Checkout 2 (but not Checkout 3 or Actinic will crash)
        5. Receipt
        Adding the onClick event to the buy-now button

        From the Design Menu select Library. Make sure the layout’s tab is selected and navigate to the Add to Cart Button group by clicking the little + by the side of the name.
        1. Double click the first item in the group which is probably Add to Cart Button
        2. Add the following code just before the /> that closes the first button-input or image-input tag.
        Code:
        onClick="SetAFCookie('<actinic:variable name="ProductReference" />','<actinic:variable name="AffiliateCommissionID" />',largeExpDate,myDomain)"
        3. Repeat this step for all the button-input and image-input tags in the template.
        4. It is important that you only include in real html input tags – i.e. don’t edit the HTML attribute of the ShowForPriceSchedule tag or the mixture of single and double quotes could cause problems.
        5. Click OK
        6. Repeat the above for all the layouts in the Add to Cart Button layout group
        Wayne Theisinger

        The Web's just settling in. We got the tech, now let's put up something that matters.

        Comment


          #5
          Building wgItems within the receipt page

          As you will remember we need to build the following string

          498::54.99::Harry%20Potter%20dvd::hpdvd93876

          Where
          498 = the Commission ID
          54.99 = the unformatted price
          Harry%20Potter%20dvd = the Product Title
          hpdvd93876 = the internal Product reference

          The commission ID has now been added to the cookie when the customer hit the Add to Cart Button and is waiting to be retrieved by us – the other information is already available within the template and the variables to hold them have already been defined in the JavaScript file that we included earlier.

          Do the following
          1. In the design tab use the dropdown to navigate to Receipt
          2. Make sure you can see the Design Tree
          Use the Design Tree to Navigate to Receipt Page Bulk > Checkout Shopping Cart Grid > Order Line List > Product Line Row > Cart Product Details and paste just below.

          <Actinic:XMLTEMPLATE NAME="ProductLine">

          the following code:
          Code:
           
          <script type="text/javascript">
          <!--                        //remove any product information link using regex
                                          myProductName = '<actinic:variable name="ProductNameOnline" />';
                                          myProductName = myProductName.replace(/<A HREF="http:\/\/.*">/g, "");
                                          myProductName = myProductName.replace(/<A HREF="https:\/\/.*">/g, "");
                                          myProductName = myProductName.replace(/<\/A>/g, "");
                                          myName = unescape(myProductName);
                                          myName = unescape(myName);
           
          //remove any HTML encoding – this is real belt and braces.
                                          while(myName.search("£")>0)
                                                          {myName=myName.replace(/£/,"");}
                                          while(myName.search(",")>0)
                                                          {myName=myName.replace(/,/,"");}
                                          while(myName.search(".")>0)
                                                          {myName=myName.replace(/./,".");}
                                          while(myName.search("&nbsp;")>0)
                                                          {myName=myName.replace(/&nbsp;/," ");}
                                          while(myName.search("<BR>")>0)
                                                          {myName=myName.replace("<BR>", "");}
                                          while(myName.search("&#")>0)
                                                          {myName=myName.replace(/&#[\d]*;/," ");}
           
                                          myProductName = myName;
           
                                           myRef = '<actinic:variable name="ProdRef" selectable="false" />';
                                          //now do the affiliate scheme
                                          //get the affiliate cookie value
                                          commissionID=GetAFCookie(myRef.toString());
                                          if(wgItems.toString()!="")
                                          {wgItems = wgItems+"|"+commissionID;
                                          }
                                          Else
                                          {
                                          wgItems = commissionID;
                                          }
                                          // -->
                                          </script>
          *(I have put the code in the file attached and you should copy and paste from there because the html entities are incorrectly displaying above)

          3. So far we’ve captured everything accept the cost of the line item so now use the Design Tree to Navigate to Receipt Page Bulk > Checkout Shopping Cart Grid > Order Line List > Product Line Row
          4. Add the following code just below the "Cost" variable.

          Code:
           <script type="text/javascript">
          <!-- 
          myCost = '<actinic:variable name="Cost" />';
          myCost = myCost.replace(/./,".");
          myCost = myCost.replace(/£/,"");
          myCost = myCost.replace(/,/,"");
           
          if(myCost!='0.00'&&myCost!=null&&myCost!=undefined&&myCost!="")
          {
          var numMyCost = myCost*1;
          if(numMyCost>0)
          {
          wgItems = wgItems+'::'+myCost+'::'+myProductName+'::'+myRef;
          }
          }
           
          // -->
          </script>
          *(I have put the code in the file attached and you should copy and paste from there because the html entities are incorrectly displaying above)

          This code will record the product name and the overall price i.e. if there are three of the product purchased the price recorded will be the overall value of all three and from this you can work backwards to the qty bought – this has always been good enough for my purposes.

          Putting it all together

          Only one step remains – that is to add wgItems to the tracking code that we added earlier so in the Design Tree navigate to the top level layout and find the tracking code at the bottom of the code directly before </body>
          Find the line that starts with “wgUri = wgProtocol + "://" + wgSubDomain “ blah blah….

          Find the end of the line which should finish with:

          Code:
          &wglocation=" + escape(document.referrer);
          And paste this code at the end before the semi-colon
          Code:
          + "&wgitems=" + escape(wgItems) + "&wgvouchercode=" + escape(wgVoucherCode)
          Which should leave with:
          Code:
          …&wglocation=" + escape(document.referrer) + "&wgitems=" + escape(wgItems) + "&wgvouchercode=" + escape(wgVoucherCode);
          Now do an upload (I normally do a refresh but I’m not sure if this is necessary). You are now fully integrated and are ready to go through your products setting commission levels on the Properties Tab of your product details ready to pass through to Webgains on the completion of sales.
          Attached Files
          Wayne Theisinger

          The Web's just settling in. We got the tech, now let's put up something that matters.

          Comment


            #6
            Hi Wayne,

            Thank you very much for posting this here, I am sure it will be very useful for other users wanting to integrate with this Affiliate scheme.

            Kind regards,
            Bruce King
            SellerDeck

            Comment


              #7
              Update for V9/10?

              Hi,

              Can anyone please advise on how this integration might differ for V9 and V10? We have a client who is keen to integrate and I wanted to check if there is any updates or amends based on replacing NETQUOTEVAR's with Variables?

              Thanks

              Alex
              Blog, Twitter, Facebook
              Actinic Ecommerce, CMS and Video production

              www.petraboase.com
              www.progrow.co.uk
              www.christopherpiperwines.co.uk
              www.cheeksandcherries.co.uk
              www.skatewarehouse.co.uk

              Comment


                #8
                I didn't have any trouble when I recently upgraded our installation of Actinic to V10 - let me know if you encounter any problems integrating.
                Wayne Theisinger

                The Web's just settling in. We got the tech, now let's put up something that matters.

                Comment


                  #9
                  Originally posted by Orchid View Post
                  I didn't have any trouble when I recently upgraded our installation of Actinic to V10 - let me know if you encounter any problems integrating.
                  Thanks for your prompt reply Wayne,

                  I appreciate that it will work, I was just wonderign if there was a more forward compatible update of the above code as I know that this is quote an onld post. Not problems if not, just wanting to make sure that no time is wasted.

                  Alex
                  Blog, Twitter, Facebook
                  Actinic Ecommerce, CMS and Video production

                  www.petraboase.com
                  www.progrow.co.uk
                  www.christopherpiperwines.co.uk
                  www.cheeksandcherries.co.uk
                  www.skatewarehouse.co.uk

                  Comment


                    #10
                    You said you don't want to waste time, but which I guess you mean you don't want to reinvent the wheel if someone had already done a solution using variables. Does this mean that you're considering having a go?

                    I haven't updated to variables as the code works so I haven't seen the need to fiddle. However if you do want to put the time in developing a variable based solution I'd be interested to see what you come up with.
                    Wayne Theisinger

                    The Web's just settling in. We got the tech, now let's put up something that matters.

                    Comment


                      #11
                      I am being asked to look into 'local tracking'. The description I got from Webgains on what/why is as follows.

                      Local tracking is something we put in place when our merchants are members of multiple affiliate networks to ensure that only one network's code will be shown after a transaction, and therefore the merchant will only have to pay commission for the sale once.

                      The way it works is that we append all of our tracking links with the source=webgains parameter. This can be anything you like, if you are using another parameter to distinguish one source from another already we can match what they have in place already. The point is that we have a unique identifier to identify a customer as coming from Webgains.

                      This is stored in a cookie on the customers computer, the local cookie. The key to implementing local tracking is to add logic that tells the website to read the local cookie and look for source=webgains, If this is present then our code must be shown on the confirmation page, if not then our code should not be displayed.

                      The other point to be clear on is that the last referrer must be credited, so if someone comes through a webgains link, leaves the site and comes back through another network's link, the last network to drop a cookie should be attributed the sale.

                      If the local cookie is not detected on the user’s machine or your local cookie does not contain a value for a referring network, then all codes should be shown on the confirmation page. The reason behind this is that there may be a chance that the user has deleted their cookies which would mean the Websites’s local cookie would have been deleted as well as the network cookies. If all tracking codes are displayed then this will allow the Webgains cookie-less tracking to be triggered and record the transaction (providing the user has previously been cookied by Webgains and within its cookie period).
                      As much as I try to understand the requirements (with Actinic in mind) I can't help wondering if someone has already done this and might know what is required.

                      Any help would be massively appreciated.

                      Alex
                      Blog, Twitter, Facebook
                      Actinic Ecommerce, CMS and Video production

                      www.petraboase.com
                      www.progrow.co.uk
                      www.christopherpiperwines.co.uk
                      www.cheeksandcherries.co.uk
                      www.skatewarehouse.co.uk

                      Comment


                        #12
                        I haven't done it myself, but I can see what they are getting at. The below is psuedo code and I haven't tested it but I think they want you to do something similar.

                        I think they want you to test for the parameter in the query string when the affiliate hits your site - then save this into a cookie.

                        Code:
                        for (var i = 0; i < nameValuePairs.length; i++) {
                                nameValuePair = nameValuePairs[i].split(/=/);
                        
                                name = nameValuePair[0];    
                                value = nameValuePair[1];
                              
                                name = name.toLowerCase();
                        
                                if (name == "source"){
                                  if (typeof(value)!="undefined"){
                                       value = value.toLowerCase();
                        
                                        if (value =="af"||value == "webgains"){
                              //*********set cookie******************//
                             SetAFCookie(name,value,largeExpDate,myDomain);
                              //*********set cookie******************//  
                                        }
                                  }       
                                }
                            }
                        Test for this in the tracking code and only display it if the cookie is present

                        Code:
                        if (GetAFCookie ("source") == "webgains" || GetAFCookie ("source") == null || wgVoucherCode != "")
                        {
                        
                        //tracking code goes here
                        
                        }
                        Wayne Theisinger

                        The Web's just settling in. We got the tech, now let's put up something that matters.

                        Comment


                          #13
                          Thanks Wayne,

                          I will take a look and see if it works. Appreciate your help here.

                          I shall post back my results just in case anyone else needs to do this in the future.

                          Alex
                          Blog, Twitter, Facebook
                          Actinic Ecommerce, CMS and Video production

                          www.petraboase.com
                          www.progrow.co.uk
                          www.christopherpiperwines.co.uk
                          www.cheeksandcherries.co.uk
                          www.skatewarehouse.co.uk

                          Comment


                            #14
                            Wayne, sorry to hassle you but what pages/templates were you referring to with the above code.

                            Alex
                            Blog, Twitter, Facebook
                            Actinic Ecommerce, CMS and Video production

                            www.petraboase.com
                            www.progrow.co.uk
                            www.christopherpiperwines.co.uk
                            www.cheeksandcherries.co.uk
                            www.skatewarehouse.co.uk

                            Comment


                              #15
                              Hi Alex,

                              No problem, I should have been more specific. The first code needs to be loaded on every page so probably the easiest place to add it would be to the end of the javascript file "affiliateScheme.js".

                              The second bit of code needs to wrap around the webgains tracking code that you will have already added to the receipt page earlier in the tutorial thread.
                              Wayne Theisinger

                              The Web's just settling in. We got the tech, now let's put up something that matters.

                              Comment

                              Working...
                              X