如何在Swift中设置Google跟踪代码管理器

时间:2022-06-28 02:49:23

I'm currently looking into setting up Google Tag Manager in iOS Swift. The Google developer docs currently don't have anything on Swift, only on Objective-C. Does anyone have any experience with setting up GTM in Swift?

我目前正在考虑在iOS Swift中设置Google跟踪代码管理器。 Google开发人员文档目前在Swift上没有任何内容,仅在Objective-C上。有没有人有在Swift中设置GTM的经验?

The current iOS docs can be found here: https://developers.google.com/tag-manager/ios/v3/

可以在此处找到当前的iOS文档:https://developers.google.com/tag-manager/ios/v3/

Thanks a lot to anyone who can point me in the right direction!

非常感谢任何能指出我正确方向的人!

2 个解决方案

#1


0  

first off I might be a bit too late in helping you here, secondly: I just started implementing this for my app today, and since I write it in Swift, I obviously have the same issue as you. However, I managed to install the SDK now and I can access the TAGManager and the code to open the container.

首先,我可能有点太晚帮助你了,其次:我刚刚开始为我的应用程序实现这个,因为我在Swift中编写它,我显然和你有同样的问题。但是,我设法现在安装了SDK,我可以访问TAGManager和代码来打开容器。

I installed the SDK using CocoaPods, so unless you also do that I can't really help you with adding the SDK to your project. I would really recommend using CocoaPods though. But since the SDK is written i ObjC you need to bridge the header files in order to use it in swift.

我使用CocoaPods安装了SDK,所以除非你也这样做,否则我无法真正帮助你将SDK添加到项目中。我真的建议使用CocoaPods。但是因为SDK是用ObjC编写的,所以你需要桥接头文件以便在swift中使用它。

Here is the CocoaPod for Google Tag Manager: https://cocoapods.org/pods/GoogleTagManager

以下是Google Tag Manager的CocoaPod:https://cocoapods.org/pods/GoogleTagManager

And here is the link I used to get the header files to bridge:http://thiagoborg.es/blog/2014/10/29/manage-objective-c-dependencies-with-cocoapods-on-swift-project/

以下是我用来连接头文件的链接:http://thiagoborg.es/blog/2014/10/29/manage-objective-c-dependencies-with-cocoapods-on-swift-project/

In the link you provided I'm currently at Getting Started - 3. Opening a Container. Unfortunately I can't get it to open, it stated that it can't find my binary.

在您提供的链接中,我目前正在使用入门 - 3.打开容器。不幸的是我无法打开它,它说它找不到我的二进制文件。

Hope this helps somewhat, though :)!

希望这有点帮助,虽然:)!

#2


0  

Anyone coming across this may have been frustrated by the rogue tutorials floating around for version 3 of Google Tag Manager. Your Bridging header will not compile !

任何遇到这种情况的人都可能因为谷歌跟踪代码管理器版本3的流氓教程而感到沮丧。您的Bridging标头将无法编译!

What you want is the version 5 of Tag Manager

你想要的是Tag Manager的第5版

https://developers.google.com/tag-manager/ios/v5/#fire-tags

https://developers.google.com/tag-manager/ios/v5/#fire-tags

#1


0  

first off I might be a bit too late in helping you here, secondly: I just started implementing this for my app today, and since I write it in Swift, I obviously have the same issue as you. However, I managed to install the SDK now and I can access the TAGManager and the code to open the container.

首先,我可能有点太晚帮助你了,其次:我刚刚开始为我的应用程序实现这个,因为我在Swift中编写它,我显然和你有同样的问题。但是,我设法现在安装了SDK,我可以访问TAGManager和代码来打开容器。

I installed the SDK using CocoaPods, so unless you also do that I can't really help you with adding the SDK to your project. I would really recommend using CocoaPods though. But since the SDK is written i ObjC you need to bridge the header files in order to use it in swift.

我使用CocoaPods安装了SDK,所以除非你也这样做,否则我无法真正帮助你将SDK添加到项目中。我真的建议使用CocoaPods。但是因为SDK是用ObjC编写的,所以你需要桥接头文件以便在swift中使用它。

Here is the CocoaPod for Google Tag Manager: https://cocoapods.org/pods/GoogleTagManager

以下是Google Tag Manager的CocoaPod:https://cocoapods.org/pods/GoogleTagManager

And here is the link I used to get the header files to bridge:http://thiagoborg.es/blog/2014/10/29/manage-objective-c-dependencies-with-cocoapods-on-swift-project/

以下是我用来连接头文件的链接:http://thiagoborg.es/blog/2014/10/29/manage-objective-c-dependencies-with-cocoapods-on-swift-project/

In the link you provided I'm currently at Getting Started - 3. Opening a Container. Unfortunately I can't get it to open, it stated that it can't find my binary.

在您提供的链接中,我目前正在使用入门 - 3.打开容器。不幸的是我无法打开它,它说它找不到我的二进制文件。

Hope this helps somewhat, though :)!

希望这有点帮助,虽然:)!

#2


0  

Anyone coming across this may have been frustrated by the rogue tutorials floating around for version 3 of Google Tag Manager. Your Bridging header will not compile !

任何遇到这种情况的人都可能因为谷歌跟踪代码管理器版本3的流氓教程而感到沮丧。您的Bridging标头将无法编译!

What you want is the version 5 of Tag Manager

你想要的是Tag Manager的第5版

https://developers.google.com/tag-manager/ios/v5/#fire-tags

https://developers.google.com/tag-manager/ios/v5/#fire-tags