Case Study: Connecting WordPress with 3rd Party APIs

Integrating WordPress with Fitbit and other APIs to Track Gestational Weight Gain and Physical Activity for a Research Study

The Research Institute of the McGill University Health Centre embarked on a pilot study to explore how digital health tools could assist women with gestational diabetes (GDM) in achieving better health outcomes. The study aimed to track physical activity and gestational weight gain (GWG) using digital tools like Fitbit devices and digital, networked scales. The overarching goal was to help participants manage their weight and activity levels effectively, thereby improving their overall health and the health of their child.

The Challenge
The original platform, developed by a third party, was responsible for collecting daily data from digital health devices, generating weekly goals, and storing the data for later analysis. However, just six months into the study, the developer announced that they would be shutting down their platform. This posed a significant challenge, as the study was expected to last another two to three years.

The challenge was to quickly develop a new system to take over the platform’s responsibilities, ensuring the study could continue without interruption. The solution needed to retrieve data from two different APIs (Fitbit and Bodytrace), store it securely, generate weekly goals based on the data, and allow researchers to monitor participant progress in real-time.

The Solution
Given the time constraints and the complexity of the requirements, WordPress was chosen as the platform for the new system. Not only was could the platform access the an API, but the system to manage hundreds of users was built-in and robust. Here’s how the solution was implemented:

  1. Data Collection:
    • The system was designed to fetch data from Fitbit via its API as needed. For Bodytrace, the data was automatically sent from the scale to the API and then to the server.
    • To minimize the risk of data loss, all data was stored on the WordPress server using the usermeta table. This ensured that data would be available if there ever were issues with the external APIs.
  2. Goal Generation:
    • The algorithm, which was initially developed for the original platform, was adapted to run within WordPress. It calculated weekly goals for GWG and physical activity (step count) based on the data collected from the devices.
    • Data was organized by week, with each participant’s daily weights, step counts, and weekly goals stored in the database. This allowed for easy comparison of goals versus actual results.
  3. Participant Management:
    • Participants were registered as WordPress users, with additional fields added to their profiles for study-specific data like due dates, weight, and height.
    • To maintain privacy, participants were identified by a code (e.g., H103 for Halifax) rather than by personal information.
  4. Dashboard and Monitoring:
    • A custom dashboard was developed to allow research assistants to monitor participant data in real-time. This included a view of all active participants, their baseline information, current data, and goals.
    • A separate page displayed a comprehensive chart of each participant’s weight, weight goals, step count, and step count goals, with options to view data for individual participants.
  5. Compliance and Intervention:
    • The biggest challenge during the study was ensuring consistent compliance from participants. To address this, the dashboard allowed research assistants to see at a glance what data was missing and intervene as needed.
    • For example, if a participant hadn’t synced their Fitbit for several days, the assistant could contact them to troubleshoot the issue and ensure accurate data collection.

Results
Despite the sudden need to pivot platforms, the WordPress-based solution was successfully implemented in time to prevent any disruption to the study. The system worked effectively for the duration of the study, handling data for 6 to 12 participants at a time. The custom dashboard allowed research assistants to manage compliance issues more efficiently, leading to better data collection and participant engagement.

Future Considerations
The success of this pilot study has laid the groundwork for future iterations, which may involve a much larger number of participants. Future versions of the system will likely need more automation to handle the increased scale, particularly in managing participant compliance and data accuracy. The flexibility and adaptability of WordPress have proven to be invaluable in this project, and the lessons learned will be applied to future studies to further refine the system. Reach out if you’d like to learn more about integrating APIs with WordPress.