Skip to content

Instantly share code, notes, and snippets.

@brandonhilkert
Forked from pjrvs/newslettercookie.html
Created May 23, 2014 15:12
Show Gist options
  • Select an option

  • Save brandonhilkert/eaee9aa9ef01004e22fc to your computer and use it in GitHub Desktop.

Select an option

Save brandonhilkert/eaee9aa9ef01004e22fc to your computer and use it in GitHub Desktop.

Revisions

  1. pjrvs revised this gist May 10, 2014. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions newslettercookie.html
    Original file line number Diff line number Diff line change
    @@ -29,6 +29,9 @@
    if (location.href.match(/utm\_source\=mailchimp/)){
    // where you use url.com?utm_source=mailchimp from within your campaigns
    $.cookie('subscriberCookie', 'subbed', { expires: 99999 });
    var newSearch = location.search.replace(/utm_.*?(&|$)/g,""), newSearch = newSearch.length > 1 ? newSearch : "";
    newSearch != location.search && window.history.replaceState({},'', location.href.replace(location.search, newSearch));

    }

    if ($.cookie('subscriberCookie')) {
  2. pjrvs revised this gist May 10, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions newslettercookie.html
    Original file line number Diff line number Diff line change
    @@ -7,9 +7,9 @@

    <body>

    <form action="http://pjrvs.us6.list-manage.com/subscribe/post?u=26857d08cfc91db6993e0bfc4&amp;id=3f954190de" method="post" class="signup">
    <input type="text" placeholder="Your Name..." name="FNAME" id="mce-FNAME">
    <input type="text" placeholder="Your Email..." name="EMAIL" id="mce-EMAIL">
    <form action="XXX" method="post" class="signup">
    <input type="text" placeholder="Your Name..." name="FNAME" id="XXX">
    <input type="email" placeholder="Your Email..." name="EMAIL" id="XXX">
    <button type="submit" class="set">GO</button>
    </form>

  3. pjrvs revised this gist May 10, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion newslettercookie.html
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,7 @@


    $(".set").on("click", function () {
    // where the button has a class of "set"
    // where a user subscribes from the form on your site
    $.cookie('subscriberCookie', 'subbed', { expires: 99999 });
    });

  4. pjrvs revised this gist May 10, 2014. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions newslettercookie.html
    Original file line number Diff line number Diff line change
    @@ -21,11 +21,13 @@
    <script>


    $(".set").on("click", function () { // where the button has a class of "set"
    $(".set").on("click", function () {
    // where the button has a class of "set"
    $.cookie('subscriberCookie', 'subbed', { expires: 99999 });
    });

    if (location.href.match(/utm\_source\=mailchimp/)){ // where you use url.com?utm_source=mailchimp
    if (location.href.match(/utm\_source\=mailchimp/)){
    // where you use url.com?utm_source=mailchimp from within your campaigns
    $.cookie('subscriberCookie', 'subbed', { expires: 99999 });
    }

  5. pjrvs created this gist May 10, 2014.
    43 changes: 43 additions & 0 deletions newslettercookie.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    <!DOCTYPE html>
    <html>
    <head>
    <title>jQuery Cookie + MailChimp</title>
    <meta charset="utf-8">
    </head>

    <body>

    <form action="http://pjrvs.us6.list-manage.com/subscribe/post?u=26857d08cfc91db6993e0bfc4&amp;id=3f954190de" method="post" class="signup">
    <input type="text" placeholder="Your Name..." name="FNAME" id="mce-FNAME">
    <input type="text" placeholder="Your Email..." name="EMAIL" id="mce-EMAIL">
    <button type="submit" class="set">GO</button>
    </form>

    <div class="subbed">You've already signed up, <a href="#">check this out</a> instead.</div>

    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>

    <script>


    $(".set").on("click", function () { // where the button has a class of "set"
    $.cookie('subscriberCookie', 'subbed', { expires: 99999 });
    });

    if (location.href.match(/utm\_source\=mailchimp/)){ // where you use url.com?utm_source=mailchimp
    $.cookie('subscriberCookie', 'subbed', { expires: 99999 });
    }

    if ($.cookie('subscriberCookie')) {
    $('.signup').hide();
    $(".subbed").show();
    } else {
    $('.signup').show();
    $('.subbed').hide();
    }

    </script>

    </body>
    </html>