Skip Navigation

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Europe/Tirane (GMT+02:00)

This topic contains 5 replies, has 2 voices.

Last updated by Marsel Nikolli 10 months, 4 weeks ago.

Assisted by: Marsel Nikolli.

Author Posts
August 14, 2024 at 2:04 pm #16070969

jessicaP-19

Background of the issue:
My website is already set up with GA4, and I'm able to see traffic data. However, there's no traffic data showing for the translation site. For instance, there's no traffic for this URL: hidden link. I need to know if I need to configure GA4 within WPML to track traffic on all translated pages and how to set this up.

Symptoms:
No traffic data showing for the translation site.

Questions:
Do I need to configure GA4 within WPML to track traffic on all translated pages?
How can I set up GA4 to track traffic on all translated pages?

August 14, 2024 at 3:02 pm #16071477

Marsel Nikolli

Hi,

Thank you for contacting WPML Support, I will gladly help you.

Can you please share WPML support debug information from your site?

* To provide the debug information:

- Login to your site and go to WPML -> Support, click on the “debug information” link at the bottom of the page.
- Once on the “debug information” page, select the entire text box content and copy it.
- Go back to our support forum, find the debug information box, and paste it.

More information on this link.

* Please do not share the debug information on the reply, just on the specific box.

Looking forward to your reply,
Marsel

August 15, 2024 at 3:32 am #16072911

jessicaP-19

Hi there, I've provided the debug information

August 15, 2024 at 8:26 am #16073342

Marsel Nikolli

Hi,

Thank you for providing the debug information.
I noticed that you are using WPML 4.6.11, I suggest you update to the latest version.

I've checked your website using the browser developer tool and on the translation version, I don't see any GA4 code.

Could you please tell me how you are implementing the GA4 code on your website (are you using any plugin or custom function)?

Looking forward to your reply,
Marsel

August 15, 2024 at 10:58 am #16074042

jessicaP-19

Hi Marsel,

So our GA tracking is done through Google Tag manager. If you go to the home page of our website and view the source code, and search for 'GTM-5WPKNFG' you will see the tag is there.

If however, you go to one of our Chinese pages, example URL being:

hidden link

And view the source code, you cannot find the GTM-5WPKNFG when doing a search. So it is not being loaded by WPML 🙁

I would rather not have to install another plugin just to get the Tag to load on WPML pages, so instead do you have a code snippet I could add which specifically hooks into WPML URLs? I ask as I have WPCodeBox on the site which is what I use to manage all my custom code snippets, so I would rather store this in there if possible.

I look forward to hearing back from you - thanks for your help

August 15, 2024 at 1:30 pm #16074613

Marsel Nikolli

Hi,

We will do our best to point you in the right direction, but please note that custom coding is beyond the scope of this support forum, we recommend that you check our contractors.

That being said, you could try the following code and check if the issue persits:

function insert_gtm_code() {
    // Replace this with your actual GTM container ID
    $gtm_container_id = 'GTM-5WPKNFG';
    
    // Define the GTM code snippet
    $gtm_code = "
    <!-- Google Tag Manager -->
    <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
    new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
    j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
    '<em><u>hidden link</u></em>);
    })(window,document,'script','dataLayer','{$gtm_container_id}');</script>
    <!-- End Google Tag Manager -->
    ";

    // Only output GTM code if it's not already present
    if ( ! strpos( wp_get_http_referer(), $gtm_container_id ) ) {
        echo $gtm_code;
    }
}

add_action('wp_head', 'insert_gtm_code', 1);

* Please ensure you have a full backup of your website before making any changes to your website.

Thank you for understanding and I hope you find this information helpful.

Let me know if you have any more questions.

Kind regards,
Marsel

The topic ‘[Closed] How to setup GA4 on WPML?’ is closed to new replies.