VisiStat Identities with Gravity Forms


/ Published in: PHP
Save to your folder(s)

VisiStat Identities with Gravity Forms


Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. // Check to see if this is an incoming link from an email campaign with an email address in the URL string
  4. if (isset($_GET['e']) && filter_var($_GET['e'], FILTER_VALIDATE_EMAIL)) {
  5.  
  6. $expire = time() + (10 * 365 * 24 * 60 * 60);
  7. setcookie("identity",$_GET['e'], $expire);
  8. $identity = $_COOKIE['identity'];
  9.  
  10. // Otherwise, look to see if a Gravity Form has been submitted ("input_3" being the email field)
  11. } elseif ( isset($_POST['input_3']) && filter_var($_POST['input_3'], FILTER_VALIDATE_EMAIL) ) {
  12.  
  13. $expire = time() + (10 * 365 * 24 * 60 * 60);
  14. setcookie("identity",$_POST['input_3'], $expire);
  15. $identity = $_COOKIE['identity'];
  16.  
  17. // If neither of the above, check to see if an identity cookie has previously been set (returning user).
  18. } elseif ( isset($_COOKIE['identity']) ) {
  19.  
  20. $identity = $_COOKIE['identity'];
  21.  
  22. // We don't know their identity yet.
  23. } else {
  24.  
  25. $identity="";
  26.  
  27. }
  28.  
  29. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.