【问题标题】:Linking to external URL with appended tracking code in Ionic 2在 Ionic 2 中使用附加的跟踪代码链接到外部 URL
【发布时间】:2017-08-17 17:18:10
【问题描述】:

我希望从我的应用程序的详细信息页面中从我的 JSON 数据中提取到外部 URL 的唯一 http 链接。

我已经安装了 inappbrowser 插件,该插件目前可与转到 apple.com 的静态 URL 配合使用。但是,我希望使用我的 JSON 数据中的产品特定链接 url。这是JSON data,它是我希望使用的“aw_deep_link”。

如何使用详情页面上的购买按钮链接到从 Angular 表达式中提取的外部 URL,然后将一些 Google Analytics 跟踪代码附加到 URL 的末尾?

这是我要附加的 Google 跟踪代码:

?utm_source=app&utm_medium=android

Here is the Plunker 目前正在使用详细信息页面上的静态 URL。

DETAIL.TS

openUrl() {

        this.platform.ready().then(() => {
            let browser = new InAppBrowser("http://www.apple.com",'_blank');
            // let browser = new InAppBrowser("www.apple.com$?utm_source=app&utm_medium=android",'_blank');
            // let browser = new InAppBrowser("{data.aw_deep_link}",'_blank');


        });
}

DETAIL.HTML

<button (click)="openUrl()" ion-item>Buy Now</button>

这是 Ionic Conference App 中用于 Twitter 页面的类似概念

https://github.com/driftyco/ionic-conference-app/blob/master/src/pages/speaker-list/speaker-list.html

【问题讨论】:

    标签: javascript typescript ionic-framework ionic2


    【解决方案1】:

    您没有在 openUrl 函数中使用 url 参数。

    <button (click)="openUrl(data.aw_deep_link)" ion-item>Buy Now</button>
    
    openUrl(url) {
        this.platform.ready().then(() => {
            let browser = new InAppBrowser(`${url}?utm_source=app&utm_medium=android`,'_blank');
            });
    }
    

    【讨论】:

    • 宾果游戏!我会勾选你的答案,非常感谢。仅供参考,为什么“让浏览器”行中需要 $?
    • ${url} 是 javascript ES6(打字稿使用)中的一项新功能,可让您更好地连接字符串。在这里阅读更多github.com/airbnb/javascript#es6-template-literals
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-08
    • 1970-01-01
    相关资源
    最近更新 更多