Capture data from page and pass to LeadsHook


#1

Is it possible to capture data from my web page - a session id for the visitor - and capture it in a LeadsHook field?

Here’s a brief video, showing what I’m trying to accomplish:
cl.ly/4f6b150f7c8f

Cheers,
Wynne


#2

Just saw the new Tracking functionality available in the node.

I’m wondering if I can use that to pass page data into LeadsHook?

Here’s a brief video, showing what I’m trying with it:

cl.ly/f641f7102214


#3

Hi @Wynne_Pirini,

Great thinking on using exit.

Spot on. That’s exactly what you’d be doing. Click the custom field and it will add {custom_field} wherever you want it to add it.

You’ll see an example here:

I’m assuming you’re already loading the tracking script using GTM or from Tracking section.

Lastly please test by activating first. I think we fire 3rd party scripts only when activated.

Nik


#4

Hi Nik,

Thanks for the info. I had a read of the knowledge base article.

I’m still not clear, though, on how to achieve my goal.

Here’s what I mean…

The LeadsHook DT is displayed on my webpage, via an iframe.

But, the sessionID is in the parent container.

Once stored in a Javascript variable, I need to pass it back into LeadsHook, and store the data in a custom variable named session_id.

Then, I’ll be able to send the sessionID to my system, along with contact info and other decision tree data, via a webhook POST request - e.g. {session_id} .

How do I do accomplish this?

Cheers,
Wynne


#5

Hi @Wynne_Pirini,

Let me get back to you on this.

One solution could be via GTM.

Let me think about this and chat with the devs to see how this can be achieved.

Are you using GTM?

Nik


#6

Pushing the session var into LH is not the issue. It’s how to capture into a custom field.

Interesting problem. :slight_smile:
Nik


#7

Wynne,

Have you added the tracking to GTM and fired same container on parent page and LH.

Since session var is issued by AutoPilot, depending on how good the their tracker is can sometimes work out it’s the same browser and person (like FB). No cross domain issues for AutoPilot since its dropping cookies from the same domain.

Nik


#8

@Wynne,

Here’s a good article on what you need to do…

Push session var into dataLayer
Grab sessein var from dataLayer

I’ll get info on how to save into custom field.

Nik


#9

The other method which I think might be better is using PostMessage.

https://datarunsdeep.com.au/blog/how-track-iframes-google-tag-manager

This is similar to what we’ve doing by passing client id from issued by GA on parent page and passing to LH embed.

Nik


#10

Hi Nik,

I’m using GTM (the cross domain one, set up using LH), and it’s the same container fired on container and LH.

As you say, Autopilot’s documentation says they use session ID to reconcile a visitor with their unique id in the system.

I’ll have a play with both methods, and see if I can get one working.

Many thanks,
Wynne


#11

I see this snippet on the datarunsdeep article, and wonder if it causes issues on some iOS devices?

However it’s worth mentioning that this approach is still not desired mainly due to restrictions in IOS that prevent the setting of 3rd party cookies when using iframes with different domains.


#12

First party or 3rd party depends on how the cookie is being dropped by AutoPilot.

GA drops 1st party cookies even in an iframe. They drop the cookie from leadshook.io not google.com. Google moved to 1st party cookies when apple did their iOS change.

So not an issue from the tech standpoint. I’d be surprised if AutoPilot drops 3rd party oookies.

Nik


#13

Hi Nik

On the container side, I’m able to push the sessionId into the datalayer, and store in a GTM variable.

To extract, on the iframe side, I’m thinking of checking the dataLayer object and extracting the value of the custom sessionId variable I created in GTM.

<script>
  var LHsessionId = dataLayer[3].autopilotSessionId);
</script>

Here’s a video showing what I’ve experimented with:
CloudApp


#14

@Wynne_Pirini,

Brilliant mate. :slight_smile:

Yes the next issue is to retrieve and to add it into a custom field.

Alternatively you could override the session id in the autopilot script that fires inside LH so then perhaps there is no need to save session id into a custom field. You’re simply override the session id in GTM. I’m guessing then there is nothing to do inside LH.

What do you think? Perhaps give that a try. Once less point of failure.

This basically means adding condition to replace session id with the one the data layer instead of generating a new one.

Hope I’m making sense.

Nik


#15

Apologies for the delay. Been thinking about your issue and seeing if there is an easier way.

There is no need to pass the info back to LH. If LH was a checkout or if you wanted to display the session id on screen then it makes sense to bring it back into LH.

But if the sole purpose if to ensure session id sync between your parent page and LH, then I don’t see any need to bring it into LH.

Unless I’m missing something with this logic.

Nik


#16

Alternatively please invite me (use leadshook @ g mail . com to your GTM account and I’ll have one of my front end devs have a look and make sure everything is working well.

Nik


#17

Hi Nik,

Thanks :slight_smile:

And, thanks for the info on cookies. I’ve checked with Autopilot support. They said the cookie is 3rd party.

I’m not 100% sure what you mean by saying to overriding session id inside LH.

But…

You comments have given me an idea. You’re right, I don’t actually need the data to be pulled back into LH, to send the data via webhook.

Since the variable is now available in GTM datalayer - both in the container, and now in the iframe - I should be able to retrieve the variable, and send it via the webhook POST request.

I’ll experiment with this approach.

Cheers,
Wynne


#18

Hi Nik,

Just realised what you’re saying with regards to bringing the sessionId from container to iframe.

So, the reason I would do it, is because the visitor builds up a history of visits on the parent container, by visiting various blog posts, landing pages, etc.

Autopilot keeps a log of all of this behaviour via the sessionId.

Once the visitor provides their email, Autopilot associates all previous, trackable behaviour with their new email address - which improves analytics and goal tracking.

With this in mind, I’m not 100% certain, but I think it’s preferable to pass the sessionId through, so it can be sent in the webhook POST request.

(I’ve prevented Autopilot web tracking tag, in GTM, from firing on iframe side)

This morning, I’ve done quite a bit of experimenting, retrieving sessionId on LH side. I can do it while working in the console (via the iframe). But, so far, I’ve been unable to actually display it in a test node, using Javascript. Here’s an example of what I tried:

<p id="test1"></p>

<script>
	var LHsessionId = dataLayer[3].autopilotSessionId;
	document.getElementById('test1').textContent = "sessionId is " + LHsessionId;
</script>

#19

Hi Wynne,
Did you checked that the var dataLayer[3] has the right content. Just so we be 100% sure it’s a rendering issue.
If you can please try console.log(dataLayer[3]) and see if it has the appropriate data.

Hamza


#20

Hi Hamza,

Yes, I’ve checked, dataLayer[3] contains the desired data.

Console.log(dataLayer[3]); contains 4 objects - of which, one is the autopilot sessionId.

It’s value is identical in both the parent container, and the iframe.

Cheers,
Wynne