When you use a landing page to present a number to a prospective caller, you might want to send information from that page to Ringba as tags to use later for things like call routing or reporting. For example, you might ask the prospective caller to click a button to indicate which age range they belong to.
With a little additional code on your web page, you can make the prospective caller's answer available to Ringba when they call your number pool number.
Important: This solution builds on the number pools feature. If you are not already familiar with number pools, see Number Pools first to learn more.
This article contains the following sections:
- Passing Tags via Query String Parameters
- Passing Tags via JavaScript on Page Load
- Passing Tags via JavaScript after Page Load
- Where to See Your Tag Values in Ringba
Passing Tags via Query String Parameters
First, Ringba already automatically captures any tags that include as parameters in your URL. For example, consider the following URL:
https://example.com/purchase.htm?lang=us-en&state=NY
This URL passes its parameters to Ringba as tags:
- lang tag value would be us-en
- state tag value would be NY
You do not need to create any JavaScript code to pass information this way.
Passing Tags via JavaScript on Page Load
To send tag values to Ringba (without any button clicks by the prospective caller), you need to insert this snippet into the <head> of your web page to initialize the rgba object. As shown below, you can include this snippet immediately after the regular number pool script:
<head>
<script src=//b-js.ringba.com/{campaign_id} async></script>
<script type="text/javascript">
window._rgba_tags = (window._rgba_tags || []);
Notice that the first line that begins with <script> is the regular number pool snippet. The second line that begins with <script> initializes the object you need.
To send tags values on page load, you continue with the following code in the <head> element:
window._rgba_tags.push({custom_id1:"custom_value1"});
</script>
</head>
Passing Tags via JavaScript after Page Load
To send Ringba tag values from button clicks by the prospective caller, you need the same first snippet in the <head> of your web page as the last example. Just as before, it initializes the rgba object. You can include it immediately after the regular number pool script:
<head>
<script src=//b-js.ringba.com/{campaign_id} async></script>
<script type="text/javascript">
window._rgba_tags = (window._rgba_tags || []);
Immediately after this code snippet, and still inside the <head> tag, you place the function that the page calls when the prospective caller clicks the button:
<script type="text/javascript"
function addTags() {
window._rgba_tags.push({custom_id2:"custom_value2"});
window._rgba_tags.push({clickID:"myvalue"}):
return;
}
</script>
</head>
Within the <body> of the web page, you call the addTags function like this:
<button onclick="addTags();">Add Tags</button>
Where to See Your Tag Values in Ringba
Ringba can use the tags you send for automations, such as routing calls based on the values. You can see the tags you collected on the call in the Call Details section of the Reporting screen. When you open a call, you can click the Tags tab to see the tags and the values.