หากต้องการขยายฟังก์ชันการทำงานของ Google Tag Manager ให้เพิ่มตัวแปรการเรียกใช้ฟังก์ชันและแท็กการเรียกใช้ฟังก์ชัน ตัวแปรการเรียกใช้ฟังก์ชันช่วยให้คุณบันทึกค่าที่แสดงผลจากการเรียกฟังก์ชันที่บันทึกไว้ล่วงหน้าได้ แท็กการเรียกใช้ฟังก์ชันช่วยให้คุณเรียกใช้ฟังก์ชันที่ลงทะเบียนไว้ล่วงหน้าได้ (เช่น เพื่อทริกเกอร์ Hit สําหรับเครื่องมือวัดผลและรีมาร์เก็ตติ้งเพิ่มเติมที่เทมเพลตแท็กใน Google Tag Manager ยังไม่รองรับในขณะนี้)
@implementationMYCustomVariable<TAGCustomFunction>-(NSObject*)executeWithParameters:(NSDictionary*)parameters{// Return the value of the custom variable.return@42;}@end
เมื่อตั้งค่าคลาสด้วย TAGCustomFunction แล้ว ให้ใช้อินเทอร์เฟซเว็บของ Tag Manager เพื่อตั้งค่าแท็กหรือตัวแปรที่มีชื่อคลาสที่คุณสร้างขึ้น
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2024-11-08 UTC"],[],["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"]]