method GetGtmProductJson()
is part of "CMS.DocumentEngine.Web.UI" but will call
EcommerceTransformationFunctions.GetGtmProductJson(SKU, additionalData, purpose)
Since you want to run it from a template I recommend you either create a Web Part that pulls the logic to code or create a User Control that does it (which you can embed directly in your template. I favor the Web Part as it's more clear when you view the Design tab it's on.