When using Sudonum for your call-tracking (and voice-call) needs, you have the ability to add meta to your tracking numbers. What is meta? Meta are key-value pairs that you can add to your number that will be included in your call detail records. The meta can then be used to distinguish between your tracking numbers and to easily group them together in whatever reporting format you are using.

Case 1:

You have a number of clients who you provide numbers for. How do you distinguish which number belongs to which client?

  • You add meta e.g. customer:Eager Energy

Case 2:

In order to test different ad campaigns, you post different numbers to different mediums. How do you assign numbers to each campaign?

  • You add meta e.g. source:Google

Case 3:

Your numbers are used in different industries or different towns. How do you group them together?

  • You add meta e.g. context:Electrician or town:Cape Town

The meta will display as a JSON object on your numbers and call detail records.

{
  'context': 'Electrician',
  'town': 'Cape Town',
  'customer': 'Eager Energy'
}
Example of meta on Number and CDR

Things to remember

You can decide what keys and values you want to use. We recommend using at least customer, context and source, but it really is up to you. The sky's the limit! No, seriously, the limit is 30 key value pairs per number. That's a lot! The only important thing to remember is consistency:

  • Use the same keys for the numbers
  • Stick to either upper or lowercase, not both
  • Don't add quotation marks, eg. customer:"Eager Energy"

Create a calculated field

Now for the exciting part! If you haven't yet set up your very own Data Studio report, go read the blog post about our new Connector or follow the easy 4-step guide.

Done? Good. The meta on your call detail record will be in a field called meta_key_value_pairs in your Data Studio report and will look like this:

(town,Cape Town);(customer,Eager Energy);(context,Electrician)
Example of meta in Data Studio

Now I'll show you how to extract fields from the meta_key_value_pairs into a calculated field by using the REGEXP_EXTRACT function in Data Studio.

Use REGEXP_EXTRACT

Make sure you are in Edit mode in the Data Studio report.

  • Click on any visualisation to see the fields in the column to the right.
  • At the bottom of the fields, click on the Create New Field button.
  • Enter a name for you new field, eg. customer_meta.
  • Copy the following and paste in the formula block:
REGEXP_EXTRACT(
    meta_key_value_pairs, 'customer,([^)]+)'
)
REGEXP_EXTRACT to extract customer meta
  • Click on Save and then Finished.

If you want to extract your source meta, just replace customer in the above formula with source, etc.

REGEXP_REPLACE

I told you earlier that it's not necessary to add quotation marks, however, if you accidentally did and your meta looks like this:

(town,Cape Town);(customer,"Eager Energy")
Example of meta with quotations

just use the REGEXP_REPLACE function to replace the quotation marks with an empty string:

REGEXP_REPLACE(
	REGEXP_EXTRACT(
    	meta_key_value_pairs, 'customer,([^)]+)'
    ), '"', ''
)
REGEXP_REPLACE to remove quotations

Case Sensitivity

Regular expressions are case-sensitive by default. If you added the key customer to one number, but Customer (notice the upper case) to another number, using the above formula will only extract the lowercase customer meta. You can make the extraction case-insensitive using the (?i) flag:

REGEXP_EXTRACT(
    meta_key_value_pairs, '(?i)customer,([^)]+)'
)
REGEXP_EXTRACT for case sensitivity

What now?

Now you can add this field to your tables, you can use it to filter or create new reports for your clients. If you don't know how to create new, filtered reports for your clients, don't panic - it’s the topic of our next blog post!