Google Tag Manager server side tracking .NET

我怕爱的太早我们不能终老 提交于 2019-12-07 05:23:47

问题


We need to push datalayer, trigger events and so on from .Net (C#) application from server side .

Google Tag Manager has JavaScript, Android and iOS SDKs. Also it has REST API, but this API allows only to manage containers, tags and events, but doesn't allow to track them.

So is it possible implement server side tracking for GTM? Seems it should be as there is SDKs for mobiles exist and it should be no big difference.

If it is possible then please let us know how and maybe there is API exists for that or SDK for .Net exists or planned in future. Maybe we have to push our data directly to Google Analytics and other endpoints? As I can see JavaScript SDK pushs data directly to GA from page.


回答1:


Some clarifications first: GTM = Client Side
GTM is not a tracking tool (although it can be used to facilitate the implementation of actual tracking tools), it is a Tag Management system. That is why it only runs on the client side (Browser JavaScript, Android/iOS SDKs are all client-side runtime environments). The REST API you are referring to is a management API to automate tasks you would normally perform manually via the GTM GUI, it doesn't change the way GTM works (that is, a client-side tool).

Using server-side code with GTM
There are several ways you can write server-side code to interact with GTM, but it ultimately has to result in some code being evaluated on the client-slide. Some examples:

  • Variables: you can create JavaScript variables via .NET which you then read on the client-side (or you can create dataLayer code directly following the same method)
  • AJAX calls: you can use the client to make AJAX calls to your server, and use the server response to trigger events, create variables, and tags.
  • Web socket: you can use a socket to push notifications from your server and once again use those to trigger event, create variables, and tags.

But once again, no matter what you do on the server-side, it must systematically lead to 1 thing: code to be evaluated on the client-side.



来源:https://stackoverflow.com/questions/33284029/google-tag-manager-server-side-tracking-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!