Skip to Content
Track your Telegram conversions with Meta Ads - Get started in minutes!

Installing AdTarget on WordPress

This guide covers two ways to add AdTarget tracking to your WordPress site: using a plugin or manual installation.

Recommended: The manual method is fastest and doesn’t require installing any plugins.

The simplest way to add tracking code to WordPress.

Access Theme Editor

Log in to your WordPress admin panel, go to Appearance → Theme File Editor, and select your active theme from the dropdown.

Edit footer.php

In the file list, click footer.php and find the closing body tag. Add the tracking code just before it:

<!-- AdTarget Tracking --> <script defer data-site="YOUR_SITE_ID" src="https://adtarget.io/tracker.min.js" ></script> </body>

Replace YOUR_SITE_ID with your actual site ID and click Update File.

Verify Installation

Visit your site and check browser DevTools for “AdTarget: initialized”.


Method 2: Using a Plugin

If you’re not comfortable editing theme files, use a code insertion plugin.

Using “Insert Headers and Footers” Plugin

Install the Plugin

Install and activate the Insert Headers and Footers plugin.

Add the Code

Go to Settings → Insert Headers and Footers. In the Scripts in Footer box, paste:

<script defer data-site="YOUR_SITE_ID" src="https://adtarget.io/tracker.min.js" ></script>

Save Changes

Replace YOUR_SITE_ID with your site ID and click Save.

Using “Code Snippets” Plugin

Install the Plugin

Install and activate the Code Snippets plugin.

Create a Snippet

Go to Snippets → Add New and name it “AdTarget Tracking”. Add this PHP code:

function adtarget_tracking_code() { echo '<script src="https://adtarget.io/tracker.min.js" data-site="YOUR_SITE_ID"></script>'; } add_action('wp_footer', 'adtarget_tracking_code');

Activate the Snippet

Replace YOUR_SITE_ID with your site ID, set it to run on “Front-end only”, and save and activate.


Method 3: Child Theme (Advanced)

If you use a child theme, add to your functions.php:

function adtarget_enqueue_tracking() { wp_enqueue_script( 'adtarget-tracker', 'https://adtarget.io/tracker.min.js', array(), null, true ); wp_script_add_data('adtarget-tracker', 'data-site', 'YOUR_SITE_ID'); } add_action('wp_enqueue_scripts', 'adtarget_enqueue_tracking');

Adding to Specific Pages Only

Using a Page Builder

If you use Elementor, Divi, or another page builder:

  1. Edit your landing page
  2. Add an HTML widget/module
  3. Paste the tracking code
  4. Save and publish

Using Conditional Logic

Add this to your theme’s functions.php to load only on specific pages:

function adtarget_conditional_tracking() { // Only load on pages with ID 123 or 456 if (is_page(array(123, 456))) { echo '<script src="https://adtarget.io/tracker.min.js" data-site="YOUR_SITE_ID"></script>'; } } add_action('wp_footer', 'adtarget_conditional_tracking');

Multiple Funnels on the Same Domain

Need different Telegram channels for different sections of your site? For example, yoursite.com and yoursite.com/uk each leading to separate channels.

How it works: Create a separate site in AdTarget for each funnel. Each site gets its own tracking code and Telegram channel.

Create Multiple Sites in AdTarget

In your AdTarget dashboard , create one site per funnel:

  • Site 1: yoursite.com → connects to your main channel
  • Site 2: yoursite.com/uk → connects to your UK channel

Create Separate Snippets

In WordPress, go to SnippetsAdd Snippet and create one snippet per funnel:

Snippet 1 (Main site):

<script defer data-site="atid_abc123" src="https://adtarget.io/tracker.min.js"></script>

Snippet 2 (UK funnel):

<script defer data-site="atid_xyz789" src="https://adtarget.io/tracker.min.js"></script>

Set Page Rules

For each snippet, use Smart Conditional Logic:

  • Snippet 1: URL does not contain /uk
  • Snippet 2: URL contains /uk

Using PHP Conditional Logic

Add this to your theme’s functions.php:

function adtarget_multi_funnel_tracking() { $uri = $_SERVER['REQUEST_URI']; if (strpos($uri, '/uk') === 0) { // UK funnel $site_id = 'atid_xyz789'; } else { // Main site $site_id = 'atid_abc123'; } echo '<script defer data-site="' . $site_id . '" src="https://adtarget.io/tracker.min.js"></script>'; } add_action('wp_footer', 'adtarget_multi_funnel_tracking');

Important: Make sure each page only loads one tracking script. Remove any global tracking code if using this method.


WordPress-Specific Tips

Caching plugins: After adding the code, clear your cache in WP Super Cache, W3 Total Cache, or your caching plugin.

Multisite installations:

  • Add the code to each site separately, or
  • Use a network-activated plugin for global tracking

Theme updates:

  • If editing theme files directly, use a child theme
  • Theme updates will overwrite your changes otherwise

Troubleshooting

Code not appearing on site?

  • Clear all caches (WordPress + browser)
  • Check if your theme uses a custom footer structure
  • Verify you’re editing the active theme

JavaScript errors in console?

  • Check for conflicts with other plugins
  • Try disabling optimization/minification plugins temporarily

Admin bar issues?

  • The tracking code is designed to work with the admin bar
  • Log out to test as a regular visitor

Need Help?

Having issues with WordPress installation? Contact support with:

  • Your WordPress site URL
  • Theme name
  • List of active plugins
  • Any error messages
Last updated on