How attendees heard about your church using execute_search

We’re back in the saddle for this week’s tutorial.

Last week, I covered how to create a custom report using CCB’s front-end interface, and how to have the report periodically emailed to you.

That’s all fine and dandy if you’re strictly using the data in excel format.

However, it it’s an entirely different story when you want to access data that’s not quite made it’s way into a formalized api service.

But never fear, there is an option for accessing data that does not have a formalized api search.

To do so, you’ll have to execute custom search to gain access to data.

How can you access non-formalized api data?

Truth be told, there are a number of methods to access CCB data.

It can be as easy as using a custom report’s output in CSV or Excel format, and parsing it using PHP or a language of your choice.  Or you could use a Pivot Table if PHP isn’t your thing. 😉

Although the aforementioned methods works, it can be more laborious based on your need.

The second option is having a 3rd-party application to directly access CCB data without the need of much, if any, manual intervention of the front-end.

You’ll learn about the second option today as well as a report that may benefit your church.

How do most attendees hear about your church?

At Mosaic Church, I spend a good bit of time asking this question to most every new face I meet.

Being in Austin with all of it’s weirdness, I’m never surprised at the how people come to know our church.

But did you know that CCB has a source or “How They Heard” option available for profiles to select. It’s a bit hidden, but I’ll show you how to located it via the front-end CCB interface.

Login into the CCB and it’ll take you to the home page screen. From the left hand menu, select People as shown below.

CCB People Search

 

For this example, I’ll search using myself. You can search using someone you know or even your very own CCB profile.

CCB People Profile

 

Once the person has been selected, it’ll take you to the person’s profile page as shown below.

CCB Selected Person Profile

 

From here, look in the far right hand column for another set of profile menus. The menu you’ll want to locate is the profile settings menu and click the Edit profile link as shown below.

CCB Profile Settings Edit Profile

 

Then, you’ll arrive at the Edit Profile page as shown below. There are tabs across the top that start with Basic and end with Admin. Click the Admin link and you’ll see the first option is “How They Heard”.

CCB Edit Profile Admin Tab

 

There are a few options to select from (see below) although your church’s administrator has privileges to add and remove necessary selections.

CCB How They Heard Options

 

Select the option that best fits or is the closest fit to how you or the person you’re updating heard about the church. Save changes and you’re done.

Accessing “How They Heard” data via the API

Now that you’ve found where the “How They Heard” option is located, it’s time to access the data via the API.

You can’t. That’s right. You can’t access the data via the API.

It seems that you should be able to access this piece of information due to it being applied to an individual profile. But no, you’t can’t access the data as it’s not returned as an XML element.

Still stumped? Okay, I’ll share with you how we’ll access the data.

Simply put, you’ll create and execute a custom search using the CCB front-end interface. I won’t show you how to create a custom search as you can review CCB’s Saved Searches.

Nevertheless, the custom search options contains a selection for “How They Heard”.

Is it all coming together how you’ll access this data?  Well, there’s one last step… actually a few steps.

Putting it all together with the API

Okay, for each “How They Heard” option, you’ll have to create a custom search for each option. Yes, I know this is time consuming, but it’s the only way to programmatically achieve the goal.

Once you’ve saved your custom search, using the Saved Searches instructions, then you’re ready to execute the saved search using the execute_search CCB API service.

I’m not going to explain each nook and cranny of code below, as you can check previous tutorials or review this tutorial.

To execute search via the api, you’ll need to obtain the query_id of the respective saved search.

The id can be obtained by click your saved search and looking for the query_id in the url address.

In the code example, the id of the executed custom search is the value of queryid variable: 229.

Now, you can retrieve customized data of each person for each “How They Heard” category, or simply access each category’s total number of individuals using sizeof() or count() methods.

<?PHP

// contains resusable globals and functions
include("includes/config.php");

$apiService = 'execute_search'; // CCB api service

$queryid = '229';  // sample field to search for (See CCB API documentation for more $apiService fields)

$urlData = array_filter( array(
	'srv' => "$apiService",
'id' => "$queryid"
	) );

$rss = ccbDetails('get',$urlData); // transform to XML

$nodes = $rss->xpath('//individuals/individual');  // xpath for individuals->individual

$response_object = '';

// to get total number, uncomment one of the following commented out lines:
// echo $totalCount = count($nodes);
// echo $totalCount = sizeof($nodes);

foreach ($nodes as $node)
{
    $response_object .= $node->full_name.' ('.$node['id'].')'."<br/>";  // now print the person's full name and age (See CCB API documentation for more $apiService fields)
}

echo $response_object;

?>

 

That’s it! So, the next time you need to access data that does not have a formalized api service, then know that you can do so and process the data using one of the following:

  • Create a custom report with CSV or Excel output that can be parsed using PHP (If you’re an Excel pro familiar with Pivot Tables)
  • Create a custom search for each option you desire to report upon and access it’s data using the execute_search service via CCB’s API

Next week, I’ll show you how to explicitly parse the “How They Heard” output via Excel file to better understand your church’s demographic and make up.  Cheers!

Related Posts

Subscribe and receive the following...

  • Inside CCB tips and tricks
  • Instant CCB tutorial alerts and updates
  • CCB How To's, Videos, Webinars and more...