Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Tag Manager server side tracking .NET

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.

like image 985
user1239646 Avatar asked Oct 31 '22 17:10

user1239646


1 Answers

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.

like image 185
Max Avatar answered Nov 09 '22 09:11

Max