💻 For Developers: PHP Hooks, The JavaScript Event And Shortcodes

New here? Not a customer yet?See everything ResultsAiX Consent can do, and get it.Get ResultsAiX Consent →

For developers and tag manager users. Everything here is optional.

Group keys

necessary, preferences, analytics, marketing, unclassified. necessary is always true.

The cookie

The answer is stored in a cookie named rxc_consent. On a multisite network every site but the main one uses its own name, rxc_consent_ followed by the site number, so a yes on one site is never read as a yes on its neighbour.

In PHP

  • rxc_has_consent( 'analytics' ) returns true or false for the current visitor. Wrap it in function_exists. Called before the plugin has finished loading, it answers false for every group but necessary.
  • rxc_consent_state() returns the whole decision as an array of group keys set to 1 or 0, or null when the visitor has not answered the current wording.
  • rxc_ask_again() raises the wording version, the same as the Ask everyone again button.
  • Action rxc_consent_recorded fires on the server each time an answer is logged, with two arguments: the groups array and the record ID.
  • Filter rxc_should_block: return false to turn blocking off for one request.
  • Filter rxc_visitor_country: return a two letter country code from your own lookup. Filter rxc_visitor_region does the same for a US state code.

In JavaScript

  • The rxc-consent event fires on document every time a decision is applied, including on each page load where a stored answer exists. Read e.detail.categories, for example e.detail.categories.marketing.
  • RXC.has('analytics') returns true or false. RXC.state() returns the whole answer or null.
  • RXC.open() opens the choices panel. RXC.acceptAll() and RXC.rejectAll() save an answer. RXC.withdraw() forgets the answer and reloads the page so the visitor is asked again.
  • An rxc_consent event is pushed to dataLayer with rxc_categories, ready to use as a Tag Manager trigger.

Holding your own script

Either add a pattern on the Blocking tab, or mark the tag up yourself: give the script type="text/plain", put its address in data-rxc-src in place of src, and add data-rxc-cat="analytics" (or another group key). The plugin leaves anything already carrying a data-rxc attribute exactly as it is, and releases it when that group is accepted.

Shortcodes

  • [rxc_cookie_table] prints the cookie declaration, grouped. Attributes: category="analytics" for one group, show_empty="yes" to include empty groups.
  • [rxc_preferences] prints a link that reopens the choices panel. Attributes: style="button", text="...".
  • [rxc_consent_date] prints the date the visitor last answered. Attribute: none="..." for the text shown before any answer.
  • [rxc_data_request] prints the data request form. Attributes: title="...", button="...".
New here? Not a customer yet?See everything ResultsAiX Consent can do, and get it.Get ResultsAiX Consent →

Ready to stop reading and start using?

Every plugin documented here works alongside the others, managed from one ResultsAiX Hub.