$ _GET在PHP中未获取utm值 [英] $_GET in PHP not getting utm values

查看:74
本文介绍了$ _GET在PHP中未获取utm值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用此PHP代码打印/回显utm_source,utm_medium和utm_campaign查询值;

I am trying to print / echo utm_source, utm_medium and utm_campaign query values using this PHP code;

echo $_GET['utm_source'];

但是奇怪的是,由于我服务器上的一些未知原因,它没有打印出值,当我将utm_source替换为诸如test_source之类的东西时,我能够看到打印出的值.

But strangely for some unknown reason on my server its not printing the values, when I replace utm_source to something else like test_source I am able to see the value in print.

从来没有遇到过这样的问题,任何人都可以在这里指导我.

Never faced any such issue, can anyone guide me here.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>
<?php echo $_GET['utm_source']; ?>

</body>
</html>

推荐答案

如果您的站点使用的是WPengine,则将无法使用PHP从URL中获取utm变量(以及utm之后的任何其他变量).出于性能原因,某些Web主机专门针对服务器请求并从服务器请求中删除这些utm参数.棘手的是,utm变量仍然保留在URL中,这意味着您可以根据需要使用Javascript来检索它们.

If your site is using WPengine, you will not be able to get the utm variables (and any additional variables after the utm's) out of the URL using PHP. Some web hosts specifically target and remove these utm parameters from server requests for performance reasons. Tricky part is, utm variables are still going remain in the URL which means that you can retrieve them using Javascript instead if you need to.

来源:WPengine文章 https://wpengine.com/support/utm-gclid-variables-caching/

这篇关于$ _GET在PHP中未获取utm值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆