Implementation to count page visits of unique visitors based on a cookie

Here’s a minimum working example… (note: this is untested code.)

add_action('init', 'custom_rsvp_handler');
function custom_rsvp_handler() {
    // for singular posts only
    // (could also check for event post type here)
    if (!is_singular()) {return;}

    // set cookie expiry length (eg. 28 days)
    $cookielength = time()+(60*60*24*28);

    // set a cookie key based on post ID
    global $post; $cookiekey = 'rsvp-'.$post->ID;

    // set global to access RSVP state in shortcode
    global $rsvp;

    // check if already visited (RSVP cookie set)
    if (isset($_COOKIE[$cookiekey])) {$rsvp = $_COOKIE[$cookiekey];}

    // check for RSVP querystring (clicked email link with ?rsvp=1)
    // (or clicked attending after clicking not attending)
    if (isset($_GET['rsvp'])) {
        $ip = $_SERVER['REMOTE_ADDR'];
        // check for email click
        if ($_GET['rsvp'] == '1') {
            $rsvp = '1'; 
            if (!isset($_COOKIE[$cookiekey])) {
                // assume this is a new click and set cookie
                setcookie($cookiekey, '1', $cookielength);
                // record the IP to the post meta
                $ips = get_post_meta($post->ID, 'rsvps');
                if ( (!is_array($ips)) || (!in_array($ip, $ips)) ) { 
                    $ips[] = $ip; update_post_meta($post->ID, 'rsvps', $ips);
                    update_post_meta($post->ID, 'rsvp-count', count($ips));
                }
            }
        } elseif ($_GET['rsvp'] == '0') {
            // user clicked not attending button
            $rsvp = '0'; setcookie($cookiekey, '0', $cookielength);
            // remove IP from attending list
            $ips = get_post_meta($post->ID, 'rsvps');
            if ( (is_array($ips)) || (in_array($ip, $ips)) ) { 
                    $index = array_search($ip, $ips); unset($ips[$index]);
                    update_post_meta($post->ID, 'rsvps', $ips);
                    update_post_meta($post->ID, 'rsvp-count', count($ips));
                }
            }
        }
    }
}

// shortcode for a non-attending button
add_shortcode('rsvp-button', 'custom_rsvp_button');
function custom_rsvp_button() {
    global $rsvp;
    if (!isset($rsvp)) {return '';}
    if ($rsvp == '1') {$action = 'I Cannot Attend'; $switch="0";}
    if ($rsvp == '0') {$action = 'I Can Attend'; $switch="1";}
    $button = '<form method="get" action="'.$_SERVER['PHP_SELF'].'">';
    $button .= '<input type="hidden" name="rsvp" value="'.$switch.'">';
    $button .= '<input type="submit" value="'.$action.'">';
    $button .= '</form>';
    return $button;
}

add_shortcode('rsvp-count', 'custom_rsvp_count');
function custom_rsvp_count() {
    global $rsvp, $post;
    if (!isset($rsvp)) {return;}
    $attendees = get_post_meta($post->ID, 'rsvp-count');
    if ($attendees) {return $attendees." Attending";}
    return '';
}

So the email link RSVP URL would be like: http://example.com/event-post/?rvsp=1

This will save a list of IPs to the event post’s meta, and set a cookie for the visitor as attending which will (roughly) prevent duplicate records.

Then you would add the shortcode [rvsp-button] into your event post content so that page visitors could click “I Cannot Attend” after visiting the page. Or “I Can Attend” if they have already clicked that they cannot. (Visitors that did not arrive through the email link will not see the button.)

UPDATE: added post meta and shortcode [rsvp-count] for outputting RSVP attending count.