Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross Domain form submit Google Tag Manager auto trigger

I have some problem while getting data from another site. In this case I want to get the reservation data from the booking engine site and they want to pass the data to me with Google Tag Manager. I don't really understand what I should do when they just need GTM code. What I should create in my server to get the data from the booking engine with Google Tag Manager ?

This is the illustrations:

I have two sites called sites1.com and sites2.com. In sites1.com I put the Google Tag Manager scripts to push form submit data like full name, last name, email, etc. After somebody submit the form I want to get the submited data in sites1.com to sites2.com with Google Tag Manager. My problem is how to get the data after somebody submited the form in sites1.com in my sites2.com ?

Please anybody knows how to resolve my problem . Thanks in advance .

like image 454
Antonio Avatar asked Jul 27 '18 03:07

Antonio


1 Answers

Well if they implement your GTM from site2.com into site1.com all you need to do is:

  1. Create a trigger for the submit button on the form (use the ID o class of the element and check for the that the Page URL contains site1.com/)
  2. Create a tag where you want the information to be send
  3. Scrap the fields with javascript or ask them to push to the dataLayer the information you need (in this case you can build the trigger based on this event)

And SUPER important: check all your triggers so no other tag fires on site1.com

2.1: Im not sure if i get where you want this information to be stored but keep in mind GA does not accept PII. On the other hand if you want this in some DB you can just create and endpoint and send the information as parameters. Example: site2.com/booking_info?field1={{DL variable}} And just use a Custom IMG tag. Ive made something like this using API Gateway, Lambda and DynamoDB and it took me 15 mins to set up. (just to give you perspective)

-- EDIT:

Ones you have the information avaliable you can send it to your database using two methods:

  • Using a HTML tag and making a request with javascript
  • Making a request with a custom image tag

GTM TAG'S

On the past i ve just added the URL with parameters where you want the request to be made on an image tag and worked perfectly for me.

-- More info:

The custom image tag requests an image from a particular URL. The interesting part is that by making the request you’re actually transmitting information to a server. For example, if you request an image via URL https://www.example.com/something?parameter1=good&parameter2=123, the receiving server processes parameter1 and parameter2 and acts accordingly (e.g. registers those parameters as an event). Source.

like image 128
Marco Avatar answered Oct 10 '22 23:10

Marco