WordPress
WordPress
You can add the LookIA widget to any WordPress site in minutes without installing a plugin. The recommended approach uses the built-in Theme Editor or a lightweight Code Snippet plugin to inject the script globally.
Method 1: Theme functions.php (Recommended)
The cleanest and most reliable way is to enqueue the script using WordPress's native wp_enqueue_script hook. This respects WordPress's asset loading system and avoids conflicts.
Open your child theme's functions.php file (go to Appearance > Theme File Editor or via FTP/SSH) and add:
<?php
// functions.php (child theme)
function lookia_enqueue_widget() {
wp_enqueue_script(
'lookia-widget',
'https://cdn.lookia.io/lookia-widget.min.js',
[], // no dependencies
null, // no version (CDN handles cache-busting)
true // load in the footer
);
// Pass the site ID as a data attribute via a late inline script
wp_add_inline_script(
'lookia-widget',
'',
'before'
);
}
add_action( 'wp_enqueue_scripts', 'lookia_enqueue_widget' );
Note: WordPress's
wp_enqueue_scriptdoes not natively supportdata-*attributes. See Method 2 for a simpler one-liner approach if you prefer to avoid the complexity.
Adding the data-site-id attribute
Since wp_enqueue_script doesn't support custom data-* attributes out of the box, use a filter to add it:
function lookia_add_data_attribute( $tag, $handle, $src ) {
if ( 'lookia-widget' !== $handle ) {
return $tag;
}
return str_replace( '<script ', '<script data-site-id="YOUR-UNIQUE-SITE-ID" ', $tag );
}
add_filter( 'script_loader_tag', 'lookia_add_data_attribute', 10, 3 );
Replace YOUR-UNIQUE-SITE-ID with your Site ID from the LookIA dashboard.
Method 2: Footer Injection via wp_footer
For a quicker setup, you can inject the raw <script> tag directly before the closing </body> tag:
function lookia_inject_widget() {
echo '<script src="https://cdn.lookia.io/lookia-widget.min.js" data-site-id="YOUR-UNIQUE-SITE-ID" defer></script>';
}
add_action( 'wp_footer', 'lookia_inject_widget' );
Add this snippet to your child theme's functions.php or use a plugin like WPCode (formerly Insert Headers and Footers) to paste it without touching theme files.
Method 3: Using a Code Snippet Plugin (No Coding Required)
If you are not comfortable editing functions.php, use a trusted WordPress plugin:
- Install and activate WPCode – Insert Headers and Footers from the WordPress plugin directory.
- Navigate to Code Snippets > Header & Footer in your WordPress admin.
- Paste the following in the Footer section:
<script src="https://cdn.lookia.io/lookia-widget.min.js" data-site-id="YOUR-UNIQUE-SITE-ID" defer></script>
- Click Save Changes.
The widget will now appear on every page of your WordPress site.
Verifying the Integration
- Visit your WordPress site in the browser.
- The LookIA floating button should appear at the bottom-right corner of every page (including the blog, single posts, and custom post types).
- Check the Allowed Domains setting in your LookIA dashboard if the widget does not appear — make sure your domain is not accidentally blocked.
Hiding the Widget on Specific Pages
If you need to hide the widget on certain pages (e.g., the checkout page of WooCommerce), use conditional tags inside the wp_footer hook:
function lookia_inject_widget() {
// Do not load on WooCommerce checkout or account pages
if ( function_exists( 'is_checkout' ) && ( is_checkout() || is_account_page() ) ) {
return;
}
echo '<script src="https://cdn.lookia.io/lookia-widget.min.js" data-site-id="YOUR-UNIQUE-SITE-ID" defer></script>';
}
add_action( 'wp_footer', 'lookia_inject_widget' );