Drupal Integration Guide
Complete guide to integrate MyFormCapture with Drupal
Integrate MyFormCapture with your Drupal website to capture leads from contact forms, webforms, and custom forms. Drupal powers over 1 million websites worldwide and offers powerful content management capabilities.
Prerequisites
- A MyFormCapture account - Sign up here
- Your MyFormCapture integration code from your dashboard
- Drupal admin access (Administrator role)
- Drupal 8.x, 9.x, or 10.x installation
- Basic understanding of Drupal modules (for custom module method)
Integration Methods
Custom Module
Create a custom Drupal module for MyFormCapture integration. This is the most maintainable and Drupal-friendly approach.
Create Module Directory
- Navigate to
/modules/custom
in your Drupal root directory - Create a new directory called
myformcapture_integration
- Create the module info file
myformcapture_integration.info.yml
name: 'MyFormCapture Integration'
type: module
description: 'Integrates MyFormCapture lead capture widget with Drupal'
package: Custom
core_version_requirement: ^8 || ^9 || ^10
version: '1.0.0'
dependencies:
- drupal:system
Important Note
Create Module Files
- Create
myformcapture_integration.module
file - Create
myformcapture_integration.libraries.yml
file - Create
js/myformcapture.js
file in your module directory
<?php
/**
* @file
* MyFormCapture Integration module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function myformcapture_integration_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.myformcapture_integration':
return '<p>' . t('MyFormCapture integration for capturing leads.') . '</p>';
}
}
/**
* Implements hook_page_attachments().
*/
function myformcapture_integration_page_attachments(array &$attachments) {
$attachments['#attached']['library'][] = 'myformcapture_integration/myformcapture';
}
Important Note
Create Library Definition
myformcapture:
js:
js/myformcapture.js: {}
dependencies:
- core/drupal
- core/jquery
Important Note
Add JavaScript File
(function ($, Drupal, drupalSettings) {
'use strict';
Drupal.behaviors.myformcaptureIntegration = {
attach: function (context, settings) {
// Use once() to ensure the script only runs once per element
$(context).find('body').once('myformcapture').each(function() {
// Load MyFormCapture script dynamically
var script = document.createElement('script');
script.src = 'https://widget.callmebackbutton.com/widget.js';
script.setAttribute('data-account', 'YOUR_ACCOUNT_ID');
script.setAttribute('data-drupal', 'true');
document.head.appendChild(script);
});
}
};
})(jQuery, Drupal, drupalSettings);
Important Note
Enable and Test Module
- Go to Extend in your Drupal admin
- Find 'MyFormCapture Integration' and check the checkbox
- Click Install
- Clear cache via Configuration → Performance → Clear all caches
- Visit your site to verify the widget appears
Important Note
Related Integrations
References & Official Documentation
Next Steps
Configure MyFormCapture
- Set up your business hours and timezone
- Configure callback phone numbers
- Set up email notifications
- Add team members to your account
Advanced Features
- Set up custom form templates
- Configure lead scoring rules
- Integrate with your CRM
- Set up automated workflows