将信息从后端发送到Google标记管理器 [英] Send info to google tag manager from backend

查看:131
本文介绍了将信息从后端发送到Google标记管理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在网站上工作时,我使用Google跟踪代码管理器并使用Javascript中的dataLayer推送一些信息。到现在为止还挺好。但是有一些信息不应该在客户端看到。因此,我想知道是否有可能在后端做同样的事情?



基本上是GTM API的请求,它相当于

  dataLayer.push({
'event':'transaction',
'something':{
'superSecret' :42
}
});

但是在后端。 (我从来没有使用GTM API,我不确定它是否允许做这种请求。如果可能的话,我将不胜感激:))。感谢!

解决方案

GTM for Web基本上是一个Javascript注入器 - 界面在那里配置您的标签,然后一切都被包装转换成插入到您的页面并由浏览器执行的JavaScript函数。没有可以将数据推送到的服务器组件。所以很可能答案是否定的(除非你想尝试真正奇怪的解决方法,比如在服务器上的无头浏览器中运行容器,或试图滥用移动SDK GTM,它的工作方式与网络版本相比有所不同)。我想将您的服务器端通话直接发送到相应的跟踪服务会更容易。


Working on a website, I use Google Tag Manager and push some info with the dataLayer in Javascript. So far so good. However there are some information that should not be seen on the client side. Therefore I'm wondering if it's possible to do the same thing on the backend?

Basically a request to GTM API that does the equivalent of

dataLayer.push({
    'event': 'transaction',
    'something': {
        'superSecret': 42
    }
});

but on backend. (I've never used GTM API and I'm not sure if it permits to do this kind of requests. If possible, I would appreciate some help :) ). Thanks!

解决方案

GTM for the Web is basically a Javascript injector - the Interface is there to configure your tags, then everything is wrapped into a JavaScript function that is inserted into your page and executed by the browser. There is no serverside component that you could push data to.

So quite probably the answer is no (unless you want to try really weird workarounds like running the container in a headless browser on your server or trying to abuse the mobile SDKs for GTM, which works rather differently than the web version). I guess it would be easier to send your serverside calls directly to the respective tracking services.

这篇关于将信息从后端发送到Google标记管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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