dongou1970 2017-01-09 03:37
浏览 54
已采纳

有没有办法使用PHP触发带有测量协议或其他服务的标签?

We are thinking of implementing analytics for our webapp so that we can trigger custom event from backend (php), google analytics doesn't have the depth we need for information like tracking emails and user status, the google tags looks promising but I can't figure out how to trigger the tag to work from backend.

Since inside tag manager we can configure custom events as trigger, I was wondering if there's a way to setup a custom trigger using measurement protocol or something similar

please excuse me if this turned out be a stupid question, thanks in advance.

  • 写回答

1条回答 默认 最新

  • dongmoyu0336 2017-01-09 09:25
    关注

    You cannot use the measurement protocol to trigger tags, since the measurement protocol is just that - a protocol. I.e. it is a description of how you have to format a http request if you expect the data to turn up in Google Analytics.

    However there is a way to set up triggers, and I guess you are simply confused with the nomenclature - GTM has an API (an "advanced programming interface"). That is a set of conventions that can be used (in pretty much any language, including PHP) to create tags, triggers and variables via server-side calls.

    The examples in the official documentation are for Java and Python, but there is an API client for PHP ( a library that provides functions to easily access Google services including GTM).

    The basic idea is that you authorize against a Google account and then call a url that depends on the action you want to take (this is REST API, where the Urls represent resources that can be accessed via http), and then send your trigger configuration in the form of a JSON object in the body of the POST request.

    What you cannot do (if that is your use case) is to trigger a tag (i.e. make a tag send data) in GTM via a server side call. GTM for the web is a javascript container that requires a client to run.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?