Skip to Content


Sends visitor data to the CRM (default: Hubspot)

JavaScript October 17, 2020


nebula.crm(action, data, callback)


(Required) (String) What will be done with the data
Default: None

(Required) (Object) The data to store
Default: None

Parameter Notes

Action can be “identify” or “event”.

Data is stored as an object of {property: value}.

Request or provide clarification »


Send multiple columns of data in the same function

nebula.crm('identify', {
    favorite_color: 'green',
    favorite_nfl_team: 'Philadelphia Eagles'

Send multiple columns of data in the same function call (using core Hubspot API, for reference). This particular example would be embedded in a PHP script.

_hsq.push(["identify", {
    ipaddress: '<?php echo $_SERVER['REMOTE_ADDR']; ?>',
    user_agent: '<?php echo $_SERVER['HTTP_USER_AGENT']; ?>',
    session_id: '<?php echo nebula()->nebula_session_id(); ?>',

Additional Notes

This function requires the Hubspot Portal ID in Nebula Options.

Source File

Located in /assets/js/nebula.js on line 1902.

nebula.crm = function(action, data, sendNow){
    if ( nebula.isDoNotTrack() ){
        return false;

    if ( typeof _hsq === 'undefined' ){
        return false;

    if ( !sendNow ){ //Set the default value for sendNow if not included
        var sendNow = true;

    if ( !action || !data || typeof data == 'function' ){
        console.error('Action and Data Object are both required.');
        ga('send', 'exception', {'exDescription': '(JS) Action and Data Object are both required in nebula.crm()', 'exFatal': false});
        return false; //Action and Data are both required.

    if ( action === 'identify' ){
        _hsq.push(["identify", data]);

        jQuery.each(data, function(key, value){
            nebula.user[key] = value;

        if ( sendNow ){
            //Send a virtual pageview because event data doesn't work with free Hubspot accounts (and the identification needs a transport method)
            _hsq.push(['setPath', window.location.href.replace(, '') + '#virtual-pageview/identify']);
        //_hsq.push(["trackEvent", data]); //If using an Enterprise Marketing subscription, use this method instead of the trackPageView above

        //Check if email was identified or just supporting data
        if ( 'email' in data ){
            if ( !nebula.user.known &&['email']) ){
                nebula.dom.document.trigger('nebula_crm_identification', {email:['email']), data: data});
                ga('send', 'event', 'CRM', 'Contact Identified', "A contact's email address in the CRM has been identified.");
                nebula.user.known = true;
        } else {
            nebula.dom.document.trigger('nebula_crm_details', {data: data});
            ga('send', 'event', 'CRM', 'Supporting Information', 'Information associated with this user has been identified.');

    if ( action === 'event' ){
        //Hubspot events are only available with an Enterprise Marketing subscription
        //Refer to this documentation for event names and IDs:
        _hsq.push(["trackEvent", data]);

        _hsq.push(['setPath', window.location.href.replace(, '') + '#virtual-pageview/' + data]);
        var oldTitle = document.title;
        document.title = document.title + ' (Virtual)';
        document.title = oldTitle;

    nebula.dom.document.trigger('crm_data', data);


To override or disable this JavaScript function, simply redeclare it with the exact same function name.

nebula.crm = function(action, data){
    //Write your own code here, leave it blank, or return false.