Last active
April 22, 2019 09:52
-
-
Save aaronfischer/8961255 to your computer and use it in GitHub Desktop.
Lead Form Tracking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*------------------------------------------------------------------- | |
* | |
* TRACK SOURCE WITH A COOKIE | |
* This will check if the query and save its values into a cookie for 180 days and will only be removed if they clear their cookies or if they visit via another source query | |
* ex. http://rmcad.edu/event/rmcad-create-day-0?utm_source=Social&utm_medium=Twitter&utm_campaign=CreateDay2.15 | |
* utm_source = Social | |
* utm_medium = Twitter | |
* utm_campaign = CreateDay2.15 | |
* | |
-------------------------------------------------------------------*/ | |
if (sourcecode = $.parseQuery().utm_source) { | |
$.cookie("lead_source_form", sourcecode, { expires: 180, path: '/' }); | |
} | |
$(".utm_source").val($.cookie("lead_source_form")); | |
if (mediumcode = $.parseQuery().utm_medium) { | |
$.cookie("lead_medium_form", mediumcode, { expires: 180, path: '/' }); | |
} | |
$(".utm_medium").val($.cookie("lead_medium_form")); | |
if (campaigncode = $.parseQuery().utm_campaign) { | |
$.cookie("lead_campaign_form", campaigncode, { expires: 180, path: '/' }); | |
} | |
$(".utm_campaign").val($.cookie("lead_campaign_form")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- include these additional plugins --> | |
<script type="text/javascript" src="../js/jquery.cookie.js"></script> | |
<script type="text/javascript" src="../js/jquery.parsequery.min.js"></script> | |
<form> | |
<!-- rest of form elements --> | |
<input class="utm_source" name="utm_source" type="hidden" value="" /> | |
<input class="utm_medium" name="utm_medium" type="hidden" value="" /> | |
<input class="utm_campaign" name="utm_campaign" type="hidden" value="" /> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For the quick and dirty procedural PHP version: