iOS 版跟踪代码管理器的高级配置
要扩展 Google 跟踪代码管理器的功能,您可以添加函数调用变量和函数调用代码。借助函数调用变量,您可以捕获预注册函数的调用所返回的值。借助函数调用代码,您可以执行预注册函数(例如,针对 Google 跟踪代码管理器中的代码模板目前不支持的其他衡量和再营销工具触发命中)。
若要创建自定义代码,请创建一个实现 TAGCustomFunction
协议的类:
@implementation MYCustomTag<TAGCustomFunction>
- (NSObject*)executeWithParameters:(NSDictionary*)parameters {
// Add custom tag implementation here.
}
@end
若要创建自定义变量,请创建一个实现 TAGCustomFunction
协议的类:
@implementation MYCustomVariable<TAGCustomFunction>
- (NSObject*)executeWithParameters:(NSDictionary*)parameters {
// Return the value of the custom variable.
return @42;
}
@end
使用 TAGCustomFunction
设置类后,请在跟踪代码管理器的网页界面中,使用您创建的类名称设置代码或变量。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-11-08。
[null,null,["最后更新时间 (UTC):2024-11-08。"],[[["Function Call variables and tags extend Google Tag Manager's capabilities by enabling custom functions."],["Function Call variables capture values from pre-registered functions, while Function Call tags execute them."],["Custom tags and variables are created by implementing the `TAGCustomFunction` protocol in a class."],["These custom classes are then utilized within Tag Manager's interface to set up new tags or variables."]]],["Function Call variables and tags in Google Tag Manager enhance its capabilities by interacting with pre-registered functions. Both utilize a class implementing the `TAGCustomFunction` protocol, with the `executeWithParameters` method defining their behavior. For a tag, this method executes custom logic; for a variable, it returns a value. After implementing the protocol in the class, you can use the Tag Manager web interface to create tags or variables by referencing the class name.\n"]]