ActiveCampaign Forum

Identifying an anonymous after submitting third party form


#1

Hi everyone.

I am using Formidable Forms on WordPress (obviously) and already have the AC tracking code running, all good. I have some native AC forms popup as modals and when a user submits them, AC then merges their previous browsing history so I can see that John Doe, while still being an anonymous user, visited XYZ pages, then submitted the form and then visited ABC pages. All good too.

I am connecting Formidable to AC via WP Fusion so I can create Contacts via Formidable forms.

So, if an anonymous user submits a Formidable form (or any other form that is not native AC for that matter) then they are never identified and continue to be anonymous as far as the tracker can see. So we gain a Contact but are totally blind a to what they did before/after joining.

Now, in Marketo (sorry but this is the only reference I can give) there is a JS API through which I can hash a user’s email address and an API key, pass it to the JS tracker which then merges all browsing data, to the current session. By doing this I can then do all sorts of things such as sending outside URLs (manually, on social media etc) that have an email address in the querystring, then as soon as they land on the website I do the hashing via on the server side and voila, the rest of their session is linked to their profile. Even if it started from a hand-written URL and on a totally new un-cookie’d device.

Is there a similar mechanism in AC through which I can pass data to the JS tracker in order to identify a user and merge their current activity to an existing profile?

(Please notice my question is about AC specifically, I understand if no one is a Formidable expert, I would take care of that, as long as I can find out how to push the data into AC’s tracking code)

Many thanks


#2

Hey @bloom360,

There is a similar way that you can id a user using a 3d party form, other than when they click a link in an email (which will ID them automatically).

In the site tracking snippet:

    <script type="text/javascript">
    	var trackcmp_email = '';
    	var trackcmp = document.createElement("script");
    	trackcmp.async = true;
    	trackcmp.type = 'text/javascript';
    	trackcmp.src = '//trackcmp.net/visit?actid=0000000&e='+encodeURIComponent(trackcmp_email)+'&r='+encodeURIComponent(document.referrer)+'&u='+encodeURIComponent(window.location.href);
    	var trackcmp_s = document.getElementsByTagName("script");
    	if (trackcmp_s.length) {
    		trackcmp_s[0].parentNode.appendChild(trackcmp);
    	} else {
    		var trackcmp_h = document.getElementsByTagName("head");
    		trackcmp_h.length && trackcmp_h[0].appendChild(trackcmp);
    	}
    </script>

There is this little line, that sets the user’s email

var trackcmp_email = '';

If you populate that variable before calling site tracking snippet (so call the site tracking snippet again after form submission, or populate that variable on the next site visit, then you should be able to ID the user.

I typically handle this in one of three ways:

  1. I save the email in localStorage, then check if it exists in localStorage everytime before calling the whole snippet.
  2. Use a tool like BigPicture.io to ID the user for you.
  3. Populate a variable in a dataLayer in GTM, and then use that variable when you call site tracking snippet via GTM.

Let me know if you need clarity on any parts of this flow!


#3

Oh, I hadn’t been notified of your reply and was quite mortified of not having a solution. Many thanks, I will try your suggestion and confirm here in case others face the same issue in the future.

Fingers crossed!


#4

OK, I tried under the following circumstances:

  1. The visitor lands on a page, it has the snippet and tracks him

  2. He fills-out the form, which submits via AJAX and on success, triggers the following code (while on the same page)

I then check in AC and the contact is surely there, but it hasn’t populated the inferred country or the session history. Which in my opinion means the identification has failed?

Is there anything wrong with the code above? Or can’t the snippet fire twice on the same page?

Many thanks!


#5

Oops this stripped the code, here it goes again:

<script type="text/javascript">
  var trackcmp_email = "hector@test.com";
  var trackcmp = document.createElement("script");
  trackcmp.async = true;
  trackcmp.type = 'text/javascript';
  trackcmp.src = '//trackcmp.net/visit?actid=0000000&e='+encodeURIComponent(trackcmp_email)+'&r='+encodeURIComponent(document.referrer)+'&u='+encodeURIComponent(window.location.href);
  var trackcmp_s = document.getElementsByTagName("script");
  if (trackcmp_s.length) {
  	trackcmp_s[0].parentNode.appendChild(trackcmp);
  } else {
  	var trackcmp_h = document.getElementsByTagName("head");
  	trackcmp_h.length && trackcmp_h[0].appendChild(trackcmp);
  }
</script>

#6

Hey @bloom360,

Check out this codepen I built for you.

Pay attention to line 36 in the javascript. This will be different because you need to change the actid from “000000” to your specific actid.

I also noticed that in the snippet you pasted above. This won’t work, you will need your specific actid there.


#7

Well duh! Very clever of me to copy paste without editing that! I had a blonde moment there.

OK so I added my act ID (I changed it here just to not advertise it, but on my website got the real one)

<script type="text/javascript">
  var trackcmp_email = "hector@test.com";
  var trackcmp = document.createElement("script");
  trackcmp.async = true;
  trackcmp.type = 'text/javascript';
  trackcmp.src = '//trackcmp.net/visit?actid=1234567&e='+encodeURIComponent(trackcmp_email)+'&r='+encodeURIComponent(document.referrer)+'&u='+encodeURIComponent(window.location.href);
  var trackcmp_s = document.getElementsByTagName("script");
  if (trackcmp_s.length) {
  	trackcmp_s[0].parentNode.appendChild(trackcmp);
  } else {
  	var trackcmp_h = document.getElementsByTagName("head");
  	trackcmp_h.length && trackcmp_h[0].appendChild(trackcmp);
  }
</script>

I tried again and doesn’t seem to be recording the geo loc, is my code still missing something?

Thanks heaps @jskole


#8

But you are seeing the site tracking event in the hector@test.com contact profile, in the right-hand sidebar?


#9

Oh! And you are sure you white-listed your domain in the tracking settings?


#10

Yes the domain is whitelisted. Whenever someone signs up not through Formidable but on a native AC modal, it does track everything beautifully. Session, geo, etc.

When I sign up through Formidable and trigger the code I posted above, I don’t get either the geo-loc or the pageviews on the right hand side.

Can you give it a quick try?

  1. https://www.zodiacsignastrology.org/sandbox/
  2. Upon submit, it will display a green success message
  3. Right-click on it > Inspect Element
  4. That shows a div class=“frm_message” … inside of it there’s a <p> inside of which is the JS code. It looks fine to me?
  5. However the Contact that gets created after that doesn’t seem to have been identified on the website. I have tried on Chrome and FF, regular window and incognito

#11

Hey @bloom360,

When I inspect the source code for that page, I don’t see the tracking snippet anywhere.


#12

It injects it via AJAX only when you submit the form, so it has to be via Inspect Element AFTER having submitted it. I believe View Source doesn’t show content that has been updated through ajax.


#13

Ah! That may be it. So you actually want the site tracking code to be installed everywhere on your site, so that you can track pagevisits as users visit different pages.


#14

It is

<script type='text/javascript' src='https://destiny.global.ssl.fastly.net/wp-content/plugins/activecampaign-subscription-forms/site_tracking.js'>

It is being injected by the WP plugin. Whenever someone signs up through the native AC modal, it tracks them everywhere, no problem.


#15

So it has the static JS from the WP plugin AND when you submit the form, it injects the other one with the email address, via ajax.


#16

Ahhhhh Interesting. Okay that makes a bit more sense.

So I just tested it, and it does look like the tracking activity is showing up in the right hand-side of the contact profile as you would expect to see, and then when I visited another page it displayed that site tracking activity as well - https://bloom360.activehosted.com/app/contacts/1899


#17

@jskole Is there any reason that trackcmp.net couldn’t return a 1x1 pixel transparent give that way you could have a “thank you” page that includes the image like this (to do the association):

<img src="https://trackcmp.net/visit?actid=1234567&e=e@example.com">


#18

If you read through the js, all that script is doing is building the script tag and calling it. The final tag ends up looking like…

<script src="https://trackcmp.net/visit?actid=1234567&e=e@example.com&u=https://example.com/current-page/"></script>

Which is not much different.

The primary reason why you would use an image pixel instead of js is to go places that js doesn’t go – that’s not many places these days. The big one is email, which is already covered if you are using AC anyway.

Functionally there is no difference.


#19

Thanks @jskole

I do see the browsing activity. My main interest is capturing the geolocation, so that I can start building my SMS campaigns timed by local time zones. Does it only capture that info if the form is native AC and not with subsequent data points from the tracker? Otherwise, can I pass the user’s IP through a custom field and somehow AC parse it? I wouldn’t want to have a separate custom country field, besides the core country/states. Does this make sense?


#20

Hi @jskole

bump

:slight_smile: