Only run identify API / set new properties if a person is not already a contact
Hello!
We send people to a page with a URL parameter that includes ?email=example@something.com, and this code below does a great job of doing what it's supposed to do – Creating a new contact from the email and giving them this property of "autocreated_pricing_page" as Yes.
However... this also just updates this "autocreated_pricing_page" parameter for someone even if they already were a contact. I'm trying to only have this property be associated with NEW contacts created from this page, not just anyone who happens to visit with the ?email= parameter in the URL.
Would there be a way to run this conditionally based on something like is-contact: false? I am fairly a newbie at this, so please excuse me if this is a crazy thing to ask. Thanks!!
_hsq.push(['trackPageView']);
function getParameterByName(name) {
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
var _hsq = window._hsq = window._hsq || [];
_hsq.push(["identify",{
email: getParameterByName("email"),
autocreated_pricing_page: true
}]);
I appreciate the response and a clue to what I could look into next but... is it okay to ask ~how~ I could use which response it returns to decide if the Identify should run?
I'm running at the extent of my dev knowledge here.
Look for an SDK in the language of your choice. We've been using this SDK for PHP.
Personally I'm more experienced with PHP so I do the heavy lifting before the page loads. If I need anything asynchronous then I use AJAX to call my PHP.