Link rewriting for affiliate codes

와, 정말 훌륭하고 교육적인 튜토리얼이네요!

JSFiddle은 제가 찾은 예시일 뿐입니다. 저희의 새로운 잠재적 파트너는 https:// 접두사를 사용하고, 끝에 제휴 ID를 붙이는 방식이 아닙니다. 그들은 adtraction.com 플랫폼을 사용합니다.

다른 분들이 활용할 수 있도록 제가 수정한 버전을 여기에 올립니다.


<script type="text/discourse-plugin" version="0.8.42">
api.decorateCookedElement(
  element => {
        const affiliate = 'https://their-ad-network.com/...';
        const affiliate_links = element.querySelectorAll('a[href*="potentialparterwebsite.com"]');

        affiliate_links.forEach(function(el) {
            if (!el.href.startsWith(affiliate)) {
                el.href = affiliate +  encodeURIComponent(el.href);
            }
        });
    },
  {
    onlyStream: true
  }
);
</script>

이제 코드가 클릭을 추적하는 광고 네트워크 URL을 먼저 추가하고, 그 뒤에 파트너 링크를 붙입니다.

3개의 좋아요