Skip to content

Commit

Permalink
Add Facebook Pixel ID setting (#507)
Browse files Browse the repository at this point in the history
  • Loading branch information
pestevez authored and JoelMarcey committed Mar 15, 2018
1 parent 56bae1d commit 5080903
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/api-site-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ customDocsPath: "website-docs"

`facebookAppId` - If you want Facebook Like/Share buttons at the bottom of your blog posts, provide a [Facebook application id](https://www.facebook.com/help/audiencenetwork/804209223039296), and the buttons will show up on all blog posts.

`facebookPixelId` - Facebook Pixel ID to track page views.

`fonts` - Font-family css configuration for the site. If a font family is specified in `siteConfig.js` as `$myFont`, then adding a `myFont` key to an array in `fonts` will allow you to configure the font. Items appearing earlier in the array will take priority of later elements, so ordering of the fonts matter.

In the below example, we have two sets of font configurations, `myFont` and `myOtherFont`. `Times New Roman` is the preferred font in `myFont`. `-apple-system` is the preferred in `myOtherFont`.
Expand Down Expand Up @@ -217,6 +219,7 @@ const siteConfig = {
scripts: [ "https://docusaurus.io/slash.js" ],
stylesheets: [ "https://docusaurus.io/style.css" ],
facebookAppId: "1615782811974223",
facebookPixelId: "352490515235776",
twitter: "true"
};
Expand Down
18 changes: 18 additions & 0 deletions lib/core/Site.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,24 @@ class Site extends React.Component {
}}
/>
)}
{this.props.config.facebookPixelId && (
<script
dangerouslySetInnerHTML={{
__html: `
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '${this.props.config.facebookPixelId}');
fbq('track', 'PageView');
`,
}}
/>
)}
{this.props.config.twitter && (
<script
dangerouslySetInnerHTML={{
Expand Down

0 comments on commit 5080903

Please sign in to comment.