Skip to content

Instantly share code, notes, and snippets.

@koni
Last active May 14, 2018 05:07
Show Gist options
  • Save koni/6e564852c2b1b806070a37b42c37f281 to your computer and use it in GitHub Desktop.
Save koni/6e564852c2b1b806070a37b42c37f281 to your computer and use it in GitHub Desktop.
ランディングページのURLを記録してSocialDogのURLを書き換える
<script type="text/javascript">
// ランディングページのパスをCookieに記録し、URLを置換する
document.addEventListener('DOMContentLoaded', function(){
var val = document.cookie.replace(/(?:(?:^|.*;\s*)sd_lp_path\s*\=\s*([^;]*).*$)|^.*$/, "$1");
var new_val = "http://blog.whotwi.com" + document.location.pathname;
if (!val) {
document.cookie="sd_lp_path=" + new_val + "; path=/;max-age=36000";
}
var utm_campaign = (val ? val + '__' + new_val : new_val);
var new_url = "https://social-dog.net/?utm_source=blog&utm_medium=web&utm_campaign=" + encodeURIComponent(utm_campaign);
$('a[href="http://bit.ly/socialdog-blog"]').attr('href', new_url)
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment