dongou1970 2017-01-08 19: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 01: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.

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

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部