WordPress Integration
Learn how to integrate ChatMaven with WordPress to add AI-powered chat support to your website.
Overviewโ
Featuresโ
- Easy installation
- Visual customization
- Page targeting
- User authentication
- Analytics integration
- Multilingual support
Installationโ
Plugin Installationโ
-
WordPress Admin
- Go to Plugins > Add New
- Search for "ChatMaven"
- Click "Install Now"
- Click "Activate"
-
Manual Installation
# Download and extract to wp-content/plugins
wget https://chatmaven.ai/downloads/wordpress.zip
unzip wordpress.zip -d /path/to/wp-content/plugins/
Configurationโ
-
API Setup
- Get API key from ChatMaven dashboard
- Enter API key in plugin settings
- Configure AI Agent settings
- Save changes
-
Basic Settings
// Example configuration
$chatmaven_config = array(
'api_key' => 'YOUR_API_KEY',
'bot_id' => 'YOUR_BOT_ID',
'language' => 'en',
'theme' => 'light'
);
Widget Setupโ
Placementโ
-
Global Integration
// Add to footer.php
<?php
if (function_exists('chatmaven_widget')) {
chatmaven_widget();
}
?> -
Specific Pages
// Conditional loading
<?php
if (is_page('contact') || is_page('support')) {
chatmaven_widget(array(
'position' => 'bottom-right',
'theme' => 'dark'
));
}
?>
Customizationโ
-
Visual Settings
/* Custom styles */
.chatmaven-widget {
--cm-primary-color: #0073aa;
--cm-font-family: 'Your Font', sans-serif;
--cm-border-radius: 12px;
} -
Behavior Settings
// Widget configuration
window.chatmavenConfig = {
autoOpen: false,
greeting: 'Welcome to our site!',
position: 'bottom-right',
offset: {
bottom: '20px',
right: '20px'
}
};
Advanced Featuresโ
User Integrationโ
-
WordPress Authentication
// User data integration
add_filter('chatmaven_user_data', function($user_data) {
if (is_user_logged_in()) {
$current_user = wp_get_current_user();
$user_data['name'] = $current_user->display_name;
$user_data['email'] = $current_user->user_email;
$user_data['role'] = $current_user->roles[0];
}
return $user_data;
}); -
Custom Fields
// Add custom user data
add_filter('chatmaven_custom_data', function($custom_data) {
$custom_data['site_language'] = get_locale();
$custom_data['theme'] = get_template();
return $custom_data;
});
Page Targetingโ
// Target specific pages
add_filter('chatmaven_show_widget', function($show) {
if (is_product() || is_cart() || is_checkout()) {
return true;
}
return $show;
});
Multilingual Supportโ
// Language detection
add_filter('chatmaven_language', function($language) {
if (function_exists('pll_current_language')) {
return pll_current_language();
}
return $language;
});
WooCommerce Integrationโ
Product Supportโ
// Add product context
add_filter('chatmaven_context', function($context) {
if (is_product()) {
global $product;
$context['product'] = array(
'name' => $product->get_name(),
'price' => $product->get_price(),
'sku' => $product->get_sku()
);
}
return $context;
});
Order Supportโ
// Add order information
add_action('woocommerce_order_status_changed', function($order_id) {
$order = wc_get_order($order_id);
chatmaven_track_event('order_updated', array(
'order_id' => $order_id,
'status' => $order->get_status()
));
});
Analyticsโ
Trackingโ
-
Event Tracking
// Track custom events
function track_chatmaven_event($event_name, $data = array()) {
do_action('chatmaven_track_event', $event_name, $data);
} -
User Analytics
// Track user interactions
add_action('wp_login', function($user_login) {
track_chatmaven_event('user_login', array(
'username' => $user_login
));
});
Reportingโ
// Generate reports
function get_chatmaven_report($start_date, $end_date) {
return ChatMaven::analytics()->getReport(array(
'start_date' => $start_date,
'end_date' => $end_date,
'metrics' => array('conversations', 'messages', 'satisfaction')
));
}
Performanceโ
Optimizationโ
-
Script Loading
// Optimize script loading
add_action('wp_enqueue_scripts', function() {
wp_enqueue_script(
'chatmaven-widget',
'https://cdn.chatmaven.ai/widget.js',
array(),
null,
true
);
}); -
Caching
// Cache configuration
add_filter('chatmaven_cache_config', function($config) {
$config['ttl'] = 3600; // 1 hour
$config['prefix'] = 'cm_cache_';
return $config;
});
Troubleshootingโ
Common Issuesโ
-
Widget Not Loading
- Check API key
- Verify script inclusion
- Check console errors
- Clear cache
-
Style Conflicts
/* Fix z-index issues */
.chatmaven-widget {
z-index: 999999 !important;
}
Debug Modeโ
// Enable debugging
define('CHATMAVEN_DEBUG', true);
// Log debug info
add_action('chatmaven_debug', function($message) {
error_log('[ChatMaven] ' . $message);
});