Cloaking Scripts Print

  • 0

Cloaking Scripts are javascript files you can include on your website to replace real numbers with tracking numbers.

Prerequisites

You'll need an account on VocalCola that has Cloaking permissions.

Responsibilities

Things to consider while editing Cloaking Scripts:

  • Changes take effect immediately. 
    If the script is already added to your website, saving changes to a Cloaking Script will not require a change to your website before taking effect.
  • Cloaking scripts set a cookie on visitors' browsers that lasts about a week, in an attempt to track how they first came to your website.
    Because of this, it's important to clear your cookies between each view during testing.
  • Rules are run from lowest weight to highest.
    The first valid rule is the one that's used.

Process

- Creating a Cloaking Script

You should see Cloaks on the top bar. Click it to see an index of all cloaking scripts related to your Clients.
https://portal.vocalcola.com/cloaks/

Click the green circled + on the toolbar to create a new Cloaking Script.
https://portal.vocalcola.com/cloaks/new.php

Select the related Client, give the new script a Title, and enter the number this script will find and replace on your website.

  • Each Script swaps a single Number, so I recommend naming each script after a Campaign.
    (All numbers associated with a campaign ring to the same place, so that ring-on number is likely what the script will be searching for.)
  • In the Number To Swap field, enter the number exactly as it appears on your site. eg (800) 555-1234 or 800.555.1234
    The script will find exactly what's in this box, and also a numeric only version of what you enter, so tel: links are also found.  eg 8005551234

Click Create and you'll be taken to the Edit page where rules can be made.

- Adding / Editing Rules

The right section of your screen will be a list of campaigns, their associated tracking numbers, and where those numbers ring to.
This is just for reference.  Rules are created in the left section.

There are Three rule types:

  • User Agent - This is an identifier string provided by web browsers.  It's useful for identifying web crawlers like Googlebot.
  • Referrer - The URL of the web page a visitor was on before reaching your site.
    Be aware that some websites intentionally do not provide Referrer values. You can work around these sites with the URL field.
  • URL - The address of the web page the script is embedded in, and loaded on.

Click a blue circled + in one of the three above sections to create a rule.

  • The Weight field is an order of importance.  Rules will be run from lowest Weight to highest, and the first rule that proves valid decides what Number will be used.
  • The Value to Find field is what will be searched for in either the User Agent, Referrer, or URL. It does not have to be an exact match, so long as what you enter is contained within.
    eg, a rule of ref=banner will be valid if the user clicked a link that took them to
    https://example.com/details/?ref=banner
  • The Show this Number field is where you enter the number that will be used if the rule proves valid.

Clicking the purple Update button will save changes, and generate the line of javascript to include on your web pages.

- Example Cloak

Example Cloak Rules

In this example cloak, the script will search your website for (800) 555-1234 (and 8005551234) and replace it based on the first valid rule, by checking each rule in order of lowest to highest weight:

  • 10 - If the User Agent contains bot, keep the 1234 number.
    • This is useful if you want search indexes to show the real number.
    • If you wanted to track calls from different organic search providers, you may want separate numbers and rules for Googlebot, Bingbot, etc.
  • 50 - If the loaded URL contains ref=banner, use a number that's labeled for tracking Banner ads.
    • Rules like this can be used to track multiple ad campaigns that hit the same page by including a unique suffix with each ad, such as ?ref=fbAd3
    • Appending references like this is actually sending a GET request to your site.  It could also be sent as #ref=banner.  That marks it as "anchor text".  If your site already uses anchor text to jump to a certain section, you may need to put the GET request version before the anchor you want to jump to.
      Like this: http://example.com?ref=banner#about-us
    • If your site already uses GET requests and you want to add to it, use & instead of ?.
      Like this: http://example.com/index.php?id=123&ref=banner
    • You may need to make rules like this for sources that don't provide referrers such as Google Maps
  • 1000 - This weight is really high and uses a part of the URL that will ALWAYS be there, so it works as an "If Everything Else Fails" rule.

If a rule is determined to be valid, the script doesn't check any weights higher.
It replaces the 1234 number with the valid number, and creates a cookie so that number can be served again in case the user navigates away and comes back.
When the script runs, if it finds this cookie, it doesn't try to validate anything, it just uses the value in the cookie.
Cookies expire after 7 days.
If you're testing your script's rules, clear your cookies between each visit.

- Adding the script to your site

On the main View Cloak page, you'll see a green Cloaking Script card, and a gray Combined Cloaking Script card (assuming you've created more than one)

The combined scripts are useful if you have multiple offices/campaigns that should trigger be cloaked on the same web pages.

Copy one the codes from the TextAreas, and paste it into the layout of your site.  (You will only need one line of code, not both)

 


Was this answer helpful?

« Back