Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Calling Custom Activity via JavaScript

The code example below is JavaScript that could be added to a page to invoke a custom activity. In this example, we're logging a custom activity when a pizza is ordered. The activity is logged when a button is clicked on the web page. Your activity could be logged in multiple ways (scroll, input, etc.). Work with your web programmer to invoke your custom activity. 

Code Block
themeEclipse
languagejs
titleCalling a Custom Activity from JavaScript
linenumberstrue
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta name="description" content="%%description%%" />
    <title>%%title%%</title>
    
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script>
      //The activity is logged on button click. 
      $(document).ready(function(){
        $('#my_activity_button').on ('click', function (){
        	
          //START: This is the code to log addthe custom activity
          ll_api.log_prospect_activity ({
              activity_identifier: 'ordered_pizza__c',
              activity_info: 'Ordered one stuffed crust pizza, with extra cheese',
              activity_fields: {
                  price__c: '13.5',
                  size__c: 'Large',
                  delivery_date__c: '2016-11-20'
              }
          }, function (response){
              console.log (response) //{success: 1, message: "Success"}
          });
          //EndEND: ofThis codeis the code to log the custom     activity
          
        })
      })
    </script>
  </head>
  <body>
    %%content%%
  </body>
</html>

...