Scrapping website content to inject in email workflow

SOLVE
Jf2
Member

Hi all,

 

Looking to set up the following process (need help with step 3):

  1. User comes to client site and creates a quote
  2. User displays exit intent, HubSpot pop up drives user to receive quote by email
  3. HubSpot to scrape the quote table from the page they are on and inject content into an email via the use of workflows/tokens or any proposed process

Thanks for all thoughts in advance.

0 Upvotes
1 Accepted solution

Accepted Solutions
Kevin-C
Solution
Recognized Expert | Partner

@Jf2 

 

Following up on my comment:

 

Checkout @amwilie 's answer to this post. This is the technique you'd want to use to get the info.

 

Write a function similar to the code below to get the data and add it to the window object:

 

$(document).ready(function() {
      // Declare your table data variable
      var tableData = [];

      $('#target tr').each(function(index) {
        // Add empty array to the tableData variable
        tableData.push([]);

        // Loop through trs and push values to the array at index
        $(this).find('td').each(function(j, el) {
          tableData[index].push(el.textContent);
        });
      });

      // Add the tableDato the window object for easy access
      window.tableData = tableData;
    });

 

You'll get a data structure like so:

Screeenshot - 2020-08-05 at 4.38.15 PM.png

 

Then write a function that populates the hidden fields in the popup. Somthing like this maybe:

$('#hidden-field-id').val(window.tableData[1][2]);

 

View solution in original post

0 Upvotes
2 Replies 2
Kevin-C
Recognized Expert | Partner

Hey @Jf2 

 

So this could be rather simple:

 

On page load capture the table data and store it on the window.

On "exit intent", popup a form with hiden field.

Populate the forms hidden field with the data from the window variable.

0 Upvotes
Kevin-C
Solution
Recognized Expert | Partner

@Jf2 

 

Following up on my comment:

 

Checkout @amwilie 's answer to this post. This is the technique you'd want to use to get the info.

 

Write a function similar to the code below to get the data and add it to the window object:

 

$(document).ready(function() {
      // Declare your table data variable
      var tableData = [];

      $('#target tr').each(function(index) {
        // Add empty array to the tableData variable
        tableData.push([]);

        // Loop through trs and push values to the array at index
        $(this).find('td').each(function(j, el) {
          tableData[index].push(el.textContent);
        });
      });

      // Add the tableDato the window object for easy access
      window.tableData = tableData;
    });

 

You'll get a data structure like so:

Screeenshot - 2020-08-05 at 4.38.15 PM.png

 

Then write a function that populates the hidden fields in the popup. Somthing like this maybe:

$('#hidden-field-id').val(window.tableData[1][2]);

 

View solution in original post

0 Upvotes