【问题标题】:Automatically Convert all external links to affiliate links自动将所有外部链接转换为附属链接
【发布时间】:2023-03-29 08:47:01
【问题描述】:

我希望能够在我的 Wordpress 和 Mybb 安装上自动将链接更改为附属链接。这将有助于减少管理链接的时间,以防将来需要更改代码,因为您知道广告客户会不断地更改关联网站。

这是我设置的 bestylish.com 会员计划。 如果网址是假设:http://www.bestylish.com/men-shoes
我需要做到这一点:- http://affiliates.tyroodr.com/ez/arttnpokwow/&lnkurl=http://www.bestylish.com/men-shoes%3Futm_source%3Dtyroo%26utm_medium%3Daffiliate%26utm_campaign%3D12june12_20percenteossoffer

在开始 www.bestylish.com 之前,我还需要一个 http:// 如果它在那里,没关系,如果它不在那里,那么我需要添加它,否则它不会被正确重定向。

同样的事情在这里:Change all website links to affiliate links automatically

但这只是在末尾附加代码,而我也必须在开头附加代码。这也不是每次都在开头添加 http:// 。 谁能帮我解决这个问题?

谢谢。

【问题讨论】:

    标签: javascript wordpress affiliate mybb external-links


    【解决方案1】:

    您可以使用一个非常相似的 jQuery 函数来更新您的链接,您只需在当前链接之前和之后添加新的 URL 信息,如下所示:

    // attach a click even to all <a> elements
    $("a").click(function() {
        addAffiliate(this);
    });
    
    // your affiliate URL and querystrig variable for redirect
    var affiliateURL = "http://affiliates.tyroodr.com/ez/arttnpokwow/?lnkurl=";
    // additional querystring values to append
    var addQueryString = "&utm_source=tyroo&utm_medium=affiliate&utm_campaign=12june12_20percenteossoffer";
    
    // function called when link is clicked
    function addAffiliate(link) {
        // make sure this link does is not to the current site and does not contain the affiliateURL
        if ((link.href).indexOf(location.host) < 0 && (link.href).indexOf(affiliateURL) < 0){
            // update the link with the affiliateURL, the url encoded link, and the additional query string
            link.href = affiliateURL + escape(link.href) + addQueryString;
        }
        alert(link.href);
        // return true to follow the link
        return true;
    }
    

    【讨论】:

    • 你好 doublesharp,我可以解决这个问题。你能在这里给我演示一下吗? : jsfiddle.net/eK7XW 谢谢
    • 这在 jsfiddle.com 上不起作用,因为它使用 location.hostname 来决定何时更新链接,您的站点将是 www.beststylish.com 但在测试中将是 jsfiddle.com .我可以说你的第二个例子是不正确的,如果你在http://beststylish.com 并点击它,结果将是http://beststylish.com/www.beststylish.com
    【解决方案2】:

    我认为您正在寻找这种类型的工作。

    请访问=>http://nullrefer.com/?http://freekaamaal.com/discuss/index.php

    加入这个论坛并尝试在线程中发布任何链接,它将转换为附属链接。 我也在寻找这种类型的脚本,但无法弄清楚它是如何圆顶的。

    最好的问候

    bbpowercis

    【讨论】:

    • 正是我想要的。但现在我得到了由开发人员构建的这个脚本:)
    【解决方案3】:

    首先,如果广告商更改他们正在使用的平台或联属网络,那么所有链接(真实链接和联属链接)都可能会发生变化,因此您需要为您推广的每个商家进行自定义操作。

    我可以建议您尝试使用一些附属链接隐藏/管理插件或服务。你可以试试 bit.ly 来管理和隐藏链接,有很多免费的 wordpress 插件可以让你做到这一点:http://wordpress.org/plugins/search.php?q=link+cloak&sort=

    如果你想要更高级的东西,你可以看看:http://autoaffiliatelinks.com/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-23
      • 2019-03-21
      • 1970-01-01
      • 1970-01-01
      • 2018-02-27
      • 2015-12-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多