This Google Tag Manager server side client template can digest any http GET or POST request incoming to your tagging server. It will generate an event object from the url's query params, request headers, cookies and request body and run a virtual container instance with your current server container configuration.
- Download the .tpl file you will find in this repository.
- Browse to your GTM container and click on 'Templates', at the bottom of the left hand side menu.
- Click on the 'New' button you will find at the top right corner of the 'Client templates' section, at the top of the screen.
- You will now be seeing the client template creation window, click on the three dots you will find at the top right corner of the screen.
- Now click on 'Import' and select the .tpl file you downloaded from this repository.
- It is important that you click on the 'Permissions' tab (top menu) and configure any necessary permissions. This client template has all the necessary API permisions set to the lowest level by default.
- When done configuring your permissions, click on 'Save', on the upper right corner of the screen
In order to start using this server-side client template in your GTM server container follow these steps:
- Browse to your GTM server container and click on 'Clients', on the left hand side menu.
- Click on 'New', and once you've accesed the client configuration screen clic on the pencil icon.
- Now select the 'Event object generator' from the custom tempalte list.
Now you are ready to configure the client's settings. These are the settings you need to configure:
- 'Origins allowed to send http requests to this end point'. The client will only accept incoming http requests from the domains you list here. If you include several of them, separate them with commas. Do not include the https:// protocol before each domain name.
- 'http request path to be claimed by the client'. The client will be waiting to claim the incoming http requests that have the path you input here.
- 'Query param containing the event name or type'. In order for the client template to successfully run a virtual instance of your GTM server container, you need to generate an object containing an event_name property. Use this field to input the incoming http request query parameter containing the event name (eg: page_view, purchase...) The client template will generate an object with an event_name property containing this query param's value
- 'Include cookie value in event object?'. If you wish to include certain cookies as part of the event object's properties, tic this checkbox. You will then be prompted to input the name of the cookie you wish to include. If including several, separat their names with commas. IMPORTANT: Cookies must be set to the same domain of the tagging server.
- 'Anonymize event object'. If you mark this checkbox, the user IP and User Agent will not be included in the event object.