【问题标题】:Pass UTM_Source to Google DFP将 UTM_Source 传递给 Google DFP
【发布时间】:2023-04-03 15:21:01
【问题描述】:

我正在寻找是否有人可以向我提供 php 代码,以便从 URL 中获取 utm_source 值并将其作为定位条件插入到 Google DFP 代码中。

不确定您还需要多少信息来提供帮助,但这是我用来获取 wordpress 类别的示例代码。这完美地进入了 DFP。需要一些可以做相同但使用 URL 的 utm_source 的东西

 <?php
    $category = get_the_category(); //Get categories
    echo 'googletag.pubads().setTargeting("category", "' .htmlspecialchars($category[0]-            
    >cat_name) . '");'; //Output first category

    ?>

【问题讨论】:

  • $_GET["utm_source"]?
  • 谢谢 - 但在 php 中看起来会如何
  • 有人可以帮忙吗?

标签: php google-dfp


【解决方案1】:

这其实很简单。首先在 DFP Admin 中定义一个动态键值(我们称之为 utm)。在这种情况下,预定义将不起作用。然后正如Marty所说,获取utm_source并输出如下:

$utm = $_GET["utm_source"];
echo 'googletag.pubads().setTargeting("category", "' .htmlspecialchars($category[0]->cat_name) . '").setTargeting("utm","'.htmlspecialchars($utm).'");

【讨论】:

  • 谢谢默特。这行得通。唯一的问题是它不会将 UTM 值存储在 cookie 中,因此它会跟随用户从一个页面到另一个页面。我能够为此获得自定义解决方案。感谢您的帮助
猜你喜欢
  • 1970-01-01
  • 2012-03-25
  • 2014-05-11
  • 2018-09-26
  • 2012-04-10
  • 1970-01-01
  • 2016-08-19
  • 2019-02-13
  • 2016-01-26
相关资源
最近更新 更多