2012-10-28 97 views
1

我希望能夠自動將鏈接更改爲我的Wordpress和Mybb安裝上的會員鏈接。這將有助於減少管理鏈接的時間,以防未來需要更改代碼,因爲您知道廣告客戶不斷更改聯屬網站。自動將所有外部鏈接轉換爲會員鏈接

這是我設置的bestylish.com聯屬計劃。 如果url是假設: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

我還需要有一個http://總是在啓動www.bestylish.com 如果有,就OK了,如果之前它不在那裏,那麼我需要添加它,否則它不會被正確重定向。

的事情同一種是在這裏:Change all website links to affiliate links automatically

但這談論只在末端附加代碼,而我要的代碼在太開始追加。此外,這不會說每次開始時都會添加http://。 任何人都可以幫助我嗎?

謝謝你。

回答

0

您可以使用一個非常類似的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; 
} 
+0

你好doublesharp,我能夠解決這個問題。你能在這裏給我演示一下嗎? :http://jsfiddle.net/eK7XW/謝謝 – Piyush

+0

這不適用於jsfiddle.com,因爲它使用'location.hostname'來決定何時更新一個鏈接,哪一個網站是www.beststylish。 com',但在測試中會是'jsfiddle.com'。我可以說,你的第二個例子是不正確的,如果你在'http:// beststylish.com'並點擊它,結果就是這個'http:// beststylish.com/www.beststylish.com' – doublesharp

0

我認爲你正在尋找這種類型工作的。

請訪問=>http://nullrefer.com/?http://freekaamaal.com/discuss/index.php

加入這個論壇,並嘗試後在線程的任何鏈接它會轉換爲會員鏈接。 我也在尋找這種類型的腳本,但無法弄清楚它是如何圓頂的。

問候

bbpowercis

+0

我在尋找。但是現在我已經獲得了由開發人員構建的這個腳本:) – Piyush

0

首先,如果廣告客戶改變他們的平臺或它們與可能所有的鏈接(不管是真實的聯盟鏈接)將改變工作affiliatet網絡,所以你需要爲你推銷的每一個商家做你的習慣。

我可以建議你嘗試擁有一些會員鏈接隱藏/管理插件或服務。您可以嘗試bit.ly來管理和斗篷鏈接,並有許多免費的WordPress插件,可以讓你做到這一點:http://wordpress.org/plugins/search.php?q=link+cloak&sort=

如果你想要的東西更先進的,你可能有一個看看:http://autoaffiliatelinks.com/