Amplitude Google Tag Manager (GTM) Server-Side Template

Related products: Data Management
Amplitude Google Tag Manager (GTM) Server-Side Template

We are excited to announce that Simo Ahava has created a new Server-Side Amplitude GTM Template. You can find this new GTM Template in the gallery.

Some of the advantages of using this server-side template include:

  • You only have to make minimal changes to your existing website tagging. The Amplitude template running in your server-side Google Tag Manager container will handle mapping the incoming requests to the format that Amplitude expects
  • You get to choose exactly what data Amplitude receives
  • You can completely remove personal data, such as the user’s IP address before the hit is sent to Amplitude
  • With server-side tagging, you can enrich the hits in the server, pulling data from your other systems before the whole package is sent to Amplitude
  • By hosting the server-side tagging endpoint (which you 100% own) on your own subdomain, you can access first-party cookies and HTTP headers when building the Amplitude request
  • You don’t need to know anything about server-side technologies or the cloud. With this template and with the familiar Google Tag Manager user interface, you can build a server-side setup quite painlessly

See how the Amplitude GTM Server-Side Template works on the blog. 

 

Wow - impressive! Like a mini CDP. Wouldn’t be my typical method of implementation but I’d give it a try on a project where backend development capacity is limited. Great work!


Keep us posted on how it goes @timothy-permutable😃


 After using this template for a while, I noticed that several requests to Amplitude servers return a “-1” status code. 

 

I was able to track this by adding the following source code snippet (highlighted below) to the template and setting template logging to “Always on”.

Unfortunately, this status code is not covered in any of the documented responses for the HTTP API.

 

Does this indicate that these requests never reached Amplitude’s tracking servers?


Logging source code snippet (Missing from previous comment)

 


Hello @panagiotis hope all is well!

Do you have a screenshot or can you share an example of the error you are seeing on your end, please? Did you encounter this error today? If so, do you have a User/Device ID for them?


Hi @eddie.gaona ,

I managed to get one of these errors while in Debug mode. I also added more details (like the Device ID and the Insert ID in the logs - thanks for the tip).

I verified that the event that returned a “-1” status code was never recorded in Amplitude. Please find a full list of details below:

  • Device ID: i7r/e2UyPNJoakFmNjaRPFvKQFmaIJ1BOeELPt9gsQI=.1661781851
  • Insert ID: i7r/e2UyPNJoakFmNjaRPFvKQFmaIJ1BOeELPt9gsQI=.1661781851collab.pageview1663923814088

Screenshot from GTM’s debugger:

Unknown response in GTM

 

Screenshot from Amplitude:

 

Full log view for that user from GCP:

Out of the 4 events, 1 was not recorded
Complete log for the problematic event

 


Hi @eddie.gaona ,

FYI, I tried to raise the GTM template’s timeout value from 1 second to 2 and I noticed that no “-1” status codes were recorded since I completed the change.